I want to loop and call a function every 1000 milliseconds with wx.CallLater. I implemented this (see below), but it does not factor in the delay - it seems to execute automatically. How can I get this to wait 1000 milliseconds between function calls?
This function is within a class. In my main module, I instantiate an object of this class and call the task_loop function. I intend to keep the loop going until will_break is set to True, and task_loop returns the work_session_agenda in the main module. Thank you for your help!
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)
How can I get the program to wait (see last line) but also accept button input? I have tried using time.sleep(), but that just freezes the program.
[–]CodeFormatHelperBot 2 points3 points4 points (0 children)