By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

I want to loop and call a function

P: 1
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!
Expand|Select|Wrap|Line Numbers
  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)
May 28 '19 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.