当前位置: 首页>>代码示例>>Python>>正文


Python Timer.clock_start方法代码示例

本文整理汇总了Python中timer.Timer.clock_start方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.clock_start方法的具体用法?Python Timer.clock_start怎么用?Python Timer.clock_start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在timer.Timer的用法示例。


在下文中一共展示了Timer.clock_start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TimerFrame

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import clock_start [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
开发者ID:BrainTech,项目名称:openbci,代码行数:49,代码来源:timer_frame.py

示例2: TagFrame

# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import clock_start [as 别名]
class TagFrame(Frame):
    def __init__(self):
        super(TagFrame, self).__init__()

    def init_frame(self, status_bar, tag_signal, params):
        self.status_bar = status_bar
        self.tag_signal = tag_signal
        self.tags = []
        self.tag = params['tag_start_name']
        self.duration = int(params['duration'])
        self.tag_on_end = params['tag_on_end']
        self.sound = params['sound']
        self.tag_title = params['name']
        self.repetitions_number = 0
        self.is_first = 0
        self.tag_signal = tag_signal
        
        if params['sound']:
            self.sound = 1
            self.player = Player()
        else:
            self.sound=0

        if self.duration:
            self.timer = Timer(self.duration, self)
            self.timer.set_position(2)
            if self.tag_on_end  != '':
                self.timer.set_stop_action(self.action_stop)

            self.stop_button = Button('stop', self)
            self.stop_button.set_position(3)
            self.stop_button.connect(self.action_stop)
            self.stop_button.set_disable()
        elif self.tag_on_end  != '':
            self.stop_button = Button('stop', self)
            self.stop_button.set_position(3)
            self.stop_button.connect(self.action_stop)
            self.stop_button.set_disable()

        self.start_button = Button('start', self)
        self.start_button.set_position(1)
        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()
#.........这里部分代码省略.........
开发者ID:BrainTech,项目名称:openbci,代码行数:103,代码来源:tag_frame.py


注:本文中的timer.Timer.clock_start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。