本文整理汇总了Python中Timer.on方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.on方法的具体用法?Python Timer.on怎么用?Python Timer.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.on方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Transition
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import on [as 别名]
class Transition(PubSub):
def __init__(self, current, next):
PubSub.__init__(self)
self.current = current
self.next = next
self.timer = Timer()
self.timer.on('tick', self.on_timer)
self.timer.on('finished', self.on_timer_finished)
self.timer.on('started', self.on_timer_started)
self.parent_temp = None
def start(self, delay=0, duration='infinite', interval=0, repeats='infinite', message_type='tick'):
if self.current.parent == None or self.current == self.next:
return
if self.current.transitioning or self.next.transitioning:
print 'stopping'
return
self.emitter = self.current._stage
self.timer.start(self.emitter, delay, duration, interval, repeats, message_type)
def on_timer_started(self):
self.current.transitioning = True
self.next.transitioning = True
self.next.transition_target = [self.current.x, self.current.y, self.next.width, self.next.height]
self.on_start()
self.emit('started')
self.parent_temp = self.next.parent
self.current.parent.add_child(self.next)
if self.current.parent.on_stage:
self.next.enter(self.current)
def on_start(self):
pass
def on_timer(self):
pass
def on_stop(self):
pass
def on_timer_finished(self, event, **kwargs):
self.emit('finished', event = event, args = kwargs)
self.current.parent.remove_child(self.current)
self.current.transitioning = False
self.next.transitioning = False
self.next.transition_target = None
if self.parent_temp is not None:
self.parent_temp.add_child(self.current)
self.current.exit(self.next)
self.on_stop()