我想循环并调用一个函数

嗨,请帮帮忙好吗?谢谢。
我想用wx.CallLater每隔1000毫秒循环和调用一个函数。我实现了这一点(见下文),但它没有考虑延迟-它似乎是自动执行的。如何让它在两次函数调用之间等待1000毫秒?
此函数位于一个类中。在我的主模块中,我实例化了这个类的一个对象并调用了TASK_LOOP函数。我打算继续循环,直到将Will_Break设置为True,并且TASK_LOOP返回主模块中的WORK_SESSION_AGING。谢谢你的帮助!

选择 | 换行 | 行号
  1. def task_loop(self, duration, window, task, work_session_agenda, start, completed):
  2. will_break = False
  3. will_continue = False
  4. duration -= datetime.timedelta(seconds=1) More code in here - which, depending on conditionals, sets the values of will_break and will_continue
  5. if will_break:
  6. print('BREAKING')
  7. return work_session_agenda
  8. else:
  9. print('GOT HERE')
  10. timer = wx.CallLater(1000, self.task_loop, duration, window, task, work_session_agenda, start, completed)

标签: python

添加新评论