我想循环并调用一个函数
嗨,请帮帮忙好吗?谢谢。
我想用wx.CallLater每隔1000毫秒循环和调用一个函数。我实现了这一点(见下文),但它没有考虑延迟-它似乎是自动执行的。如何让它在两次函数调用之间等待1000毫秒?
此函数位于一个类中。在我的主模块中,我实例化了这个类的一个对象并调用了TASK_LOOP函数。我打算继续循环,直到将Will_Break设置为True,并且TASK_LOOP返回主模块中的WORK_SESSION_AGING。谢谢你的帮助!
选择 | 换行 | 行号
- def task_loop(self, duration, window, task, work_session_agenda, start, completed):
- will_break = False
- will_continue = False
- duration -= datetime.timedelta(seconds=1) More code in here - which, depending on conditionals, sets the values of will_break and will_continue
- if will_break:
- print('BREAKING')
- return work_session_agenda
- else:
- print('GOT HERE')
- timer = wx.CallLater(1000, self.task_loop, duration, window, task, work_session_agenda, start, completed)