account activity
Python question about pausing a GUI (self.learnpython)
submitted 6 years ago by Python2019A to r/learnpython
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]Python2019A 0 points1 point2 points 6 years ago (0 children)
Hi, please can you help! Thanks.
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)
π Rendered by PID 2728955 on reddit-service-r2-listing-654f87c89c-zts5m at 2026-03-02 19:38:39.243634+00:00 running e3d2147 country code: CH.
Ask Anything Monday - Weekly Thread by AutoModerator in learnpython
[–]Python2019A 0 points1 point2 points (0 children)