本文整理汇总了Python中timer.Timer.clock_reset方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.clock_reset方法的具体用法?Python Timer.clock_reset怎么用?Python Timer.clock_reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.clock_reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TimerFrame
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import clock_reset [as 别名]
class TimerFrame(Frame):
def __init__(self):
super(TimerFrame, self).__init__()
def init_frame(self, params):
self.duration=int(params['duration'])
self.timer = Timer(self.duration, self)
self.timer.set_position(1)
self.timer.set_stop_action(self.action_stop)
self.stop_button = Button('stop', self)
self.stop_button.set_position(2)
self.stop_button.connect(self.action_stop)
self.set_off()
def action_start(self):
self.stop_button.set_enable()
self.timer.clock_start()
def action_stop(self):
self.finish_action_elier_frame()
if self.timer.is_on:
self.timer.clock_stop()
self.stop_button.set_disable()
self.set_is_off()
self.active_next_frame()
def set_on(self):
self.timer.clock_reset()
self.stop_button.set_enable()
self.action_start()
self.set_is_on()
def set_off(self):
if self.timer.is_on:
self.timer.clock_stop()
self.timer.clock_reset()
self.stop_button.set_disable()
self.set_is_off()
def finish_frame_action(self):
self.set_off()
self.next_frame.remove(self.next_frame[0])
print self, self.next_frame
示例2: TagFrame
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import clock_reset [as 别名]
#.........这里部分代码省略.........
self.start_button.connect(self.action_start)
self.clear_button=Button('clear', self)
self.clear_button.set_position(4)
self.clear_button.connect(self.action_clear)
self.tag_title = QtGui.QLabel('{}:'.format(self.tag_title), self)
self.tag_title.move(10, 3)
self.set_off()
def _create_tag(self, tag):
self.tags.append({'timestamp':str(time.time()), 'name':str(tag)})
def _create_status_bar_message(self, type_, tag):
if type_ == 'create':
return "Tag: {} was create.".format(tag)
else:
names = [name for name in [t['name'] for t in tag]]
if type_ == 'delete':
if len(names) == 1:
return "Tag: {} was delete.".format(''.join(names))
else:
return "Tags: {} were delate.".format(', '.join(names))
elif type_ == 'send':
if len(names) == 1:
return "Tag: {} was send.".format(''.join(names))
else:
return "Tags: {} were send.".format(', '.join(names))
def action_start(self):
if self.sound:
self.player.play()
if (not self.repetitions_number) and (not self.is_first):
self.finish_action_elier_frame()
self.start_button.set_disable()
self._create_tag(self.tag)
self.status_bar.show_message(self._create_status_bar_message('create', self.tag))
if self.duration:
self.stop_button.set_enable()
self.timer.clock_start()
elif self.tag_on_end != '':
self.stop_button.set_enable()
else:
self.active_next_frame()
def action_stop(self):
if self.sound:
self.player.play()
if self.duration and self.timer.is_on:
self.timer.clock_stop()
if self.tag_on_end != '':
self._create_tag(self.tag_on_end)
self.status_bar.show_message(self._create_status_bar_message('create', self.tag_on_end))
self.stop_button.set_disable()
self.active_next_frame()
def _update_repetition(self):
self.repetitions_number+=1
def action_clear(self):
self.status_bar.show_message(self._create_status_bar_message('delete', self.tags))
self.tags = []
self.set_on()
self.deactivation_next_frame()
if self.duration:
self.timer.clock_reset()
self._update_repetition()
def set_on(self):
self.start_button.set_enable()
if self.duration:
self.timer.clock_reset()
self.stop_button.set_enable()
self.clear_button.set_enable()
self.set_is_on()
def set_off(self):
self.clear_button.set_disable()
if self.duration:
self.stop_button.set_disable()
self.start_button.set_disable()
self.set_is_off()
def _send_tags(self):
for tag in self.tags:
self.tag_signal.emit(str(tag))
self.tags = []
def finish_frame_action(self):
self.status_bar.show_message(self._create_status_bar_message('send', self.tags))
self._send_tags()
self.set_off()
self.next_frame.remove(self.next_frame[0])
if self.is_first:
self.is_first=0
print self, self.next_frame