本文整理汇总了Python中timer.Timer.start_stop方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.start_stop方法的具体用法?Python Timer.start_stop怎么用?Python Timer.start_stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.start_stop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameClock
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import start_stop [as 别名]
class GameClock(object):
def __init__(self, counter = 20, fischer = 0):
self.init(counter, fischer)
def init(self, counter = 20, fischer = 0):
self.timer1 = Timer(counter, fischer)
self.timer2 = Timer(counter, fischer)
def start(self):
self.timer1.start()
def next(self):
if(self.timer1.time == self.timer2.time == None):
self.timer1.start()
else:
self.timer1.start_stop()
self.timer2.start_stop()
def interrupt(self):
self.timer1.interrupt()
self.timer2.interrupt()
def get_counters(self):
return [ self.timer1.get_formatted_counter(),
self.timer2.get_formatted_counter(),
self.turn_id() ]
def turn_id(self):
if self.timer1.time == None:
if self.timer2.time == None:
return 1
else:
return 2
else:
if self.timer2.time == None:
return 1
raise Warning('The 2 timers are started at the same time')
示例2: test_start_stop
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import start_stop [as 别名]
def test_start_stop(self):
timer = Timer()
timer.start_stop()
self.assertNotEqual(timer.time, None)
timer.start_stop()
self.assertEqual(timer.time, None)