本文整理汇总了Python中timer.Timer.idle方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.idle方法的具体用法?Python Timer.idle怎么用?Python Timer.idle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.idle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: painter_test2
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import idle [as 别名]
def painter_test2(n, lines, columns, fps = 25000):
# test main-thread execution (previewer run as main thread):
preview = Preview(title = "Main-thread test without diagram",
lines = lines, columns = columns, fps_limit = fps,
painter_class = TestPainter)
timer = Timer(0.1)
preview.interactive(True)
preview.start()
step = 0
# create tests in different threads
while True:
step += 1
preview.set_title("Test #" + str(step) + " ADD-del inverse order")
painters = []
for i in xrange(0,n):
painters.append(preview.add_view(i))
while timer.idle():
if not preview.step():
return
preview.set_title("Test #" + str(step) + " add-DEL inverse order")
while len(painters) > 0:
preview.del_view(painters.pop())
while timer.idle():
if not preview.step():
return
preview.set_title("Test #" + str(step) + " ADD-del direct order")
painters = []
for i in xrange(0,n):
painters.append(preview.add_view(i))
while timer.idle():
if not preview.step():
return
preview.set_title("Test #" + str(step) + " add-DEL direct order")
for i in xrange(0,n):
preview.del_view(painters[i])
while timer.idle():
if not preview.step():
return
preview.set_title("Test #" + str(step) + " ADD-del random order")
painters = []
for i in xrange(0,n):
painters.append(preview.add_view(i))
while timer.idle():
if not preview.step():
return
preview.set_title("Test #" + str(step) + " add-DEL random order")
while len(painters) > 0:
i = random.randint(0, len(painters) - 1)
preview.del_view(painters[i])
del painters[i]
while timer.idle():
if not preview.step():
return
示例2: Preview
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import idle [as 别名]
#.........这里部分代码省略.........
pygame.display.set_caption(title)
def add_view(self, view, label='', painter_class = None):
'''
Include a diagram in previewer
'''
assert view is not None
with self.lock:
# prevent drawing duplication of same object
if view in self.views:
return False
# create a painter to object
if painter_class is None:
painter = self.default_painter_class(self.count_painters,
view, label)
else:
painter = painter_class(self.count_painters, view, label)
self.count_painters += 1
# make control
self.grid.add_painter(painter)
self.views[view] = painter
return view
def del_view(self, view):
assert view is not None
with self.lock:
if view in self.views:
painter = self.views[view]
self.grid.del_painter(painter)
del self.views[view]
def pause(self, delay = 0.0):
'''
Defines a idle time to previewer
'''
self.frame_timer.pause(delay)
def stop(self):
'''
Request the termination of panel
'''
self.state = Preview.KILLED
def is_running(self):
'''
Verify if previewer state is RUNNING
'''
return self.state == Preview.RUNNING
def interactive(self, interact):
'''
Defines if previewer works as a separate thread or not
'''
if self.state == Preview.STARTING:
self.threading = not interact
def start(self):
'''
Starts previewer
'''
# Initialization
pygame.init()
self.state = Preview.RUNNING
if self.threading:
threading.Thread.__init__(self)
threading.Thread.start(self)