[Tutor] Reusing Timers (threading.timer)
Patrick Dickey
pdickeybeta at gmail.com
Tue Nov 13 16:42:55 CET 2012
Hi everyone,
I've got an application that will use a timer to run a function
automatically (it's an update function for my IPv6 endpoint). The
questions that I have are these:
1. Can I stop and start the timer from different functions or methods
in my program, and if so, how?
2. Can I stop the timer, change the value, and restart it (or would it
create a new timer), or do I have to create a new timer with an entirely
new name?
3. If I get a value from a textbox, how do I parse it from the string
value to an integer (or float)?
4. Is there a better way of accomplishing this task?
Here's the pseudocode for what I'm doing.
if autoUpdates is enabled
get updateFrequency
start timer with time value from updateFrequency
when time is reached, run update method
else
cancel timer
if autoUpdates is enabled AND user changes updateFrequency
stop timer
get updateFrequency
start timer with new time value from updateFrequency
The autoUpdates and updateFrequency are a checkbox and text box in
wxPython.
Thanks for any advice on this, and have a great day.:)
Patrick.
More information about the Tutor
mailing list