本文整理汇总了Python中timer.Timer.sleep方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.sleep方法的具体用法?Python Timer.sleep怎么用?Python Timer.sleep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类timer.Timer
的用法示例。
在下文中一共展示了Timer.sleep方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wait_for_task_to_complete
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import sleep [as 别名]
def wait_for_task_to_complete(self, timeout=600):
timer = Timer()
timer.start()
while True:
timer.print_time_elapsed()
print("Checking status of task.")
if timer.has_timeout(timeout):
raise TimeOutError("Task timed out after " + str(timeout) +
" seconds.")
if self.is_task_completed():
print("Task Completed!")
return
timer.sleep(3)
示例2: TableWindow
# 需要导入模块: from timer import Timer [as 别名]
# 或者: from timer.Timer import sleep [as 别名]
#.........这里部分代码省略.........
self.cols.append(self.col_five_edit)
self.cols.append(self.col_six_edit)
self.cols.append(self.col_seven_edit)
self.cols.append(self.col_eight_edit)
self.cols.append(self.col_nine_edit)
self.cols.append(self.col_ten_edit)
def read_table(self):
"""Прочита таблицата от Table и я попълва в UI-a.
Ако има победител, пуска нов прозер.
"""
result = ""
i = 0
for col in self.cols:
for j in range(0, len(self.t.matrix)):
result += self.t.matrix[j][i] + "\n-\n"
i += 1
col.setText(result)
result = ""
if self.t.has_winner():
if self.t.get_winner() == Table.RED:
print(self.first_player_time.stop())
self.player_game_time.setText(str(self.first_player_time.stop()))
self.win_dialog.show()
else:
self.compuret_win.show()
def first_button_clicked(self):
"""Метод, който се извиква при натискането на първия бутон.
Извършва ход в играта на позиция 0.
"""
if self.onTurn == 1:
self.t.commit_turn(0, "R")
self.first_player_time.sleep()
if self.vsPC:
pos = self.pc.get_turn(self.t.matrix)
self.t.commit_turn(pos, "B")
self.first_player_time.start()
else:
self.onTurn = 2
self.player.setText("B")
else:
self.t.commit_turn(0, "B")
self.player.setText("R")
self.onTurn = 1
self.first_player_time.start()
self.read_table()
def second_button_clicked(self):
"""Метод, който се извиква при натискането на втория бутон.
Извършва ход в играта на позиция 1.
"""
if self.onTurn == 1:
self.t.commit_turn(1, "R")
self.first_player_time.sleep()
if self.vsPC:
self.t.commit_turn(self.pc.get_turn(
self.t.matrix), "B")
self.first_player_time.start()
else:
self.onTurn = 2
self.player.setText("B")
else:
self.t.commit_turn(1, "B")
self.player.setText("R")
self.onTurn = 1