[Tutor] Reusing Timers (threading.timer)
Alan Gauld
alan.gauld at btinternet.com
Tue Nov 13 18:32:31 CET 2012
On 13/11/12 15:42, Patrick Dickey wrote:
> 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?
I can't help with threading.timer since I've never used it but...
> 3. If I get a value from a textbox, how do I parse it from the string
> value to an integer (or float)?
Use int() or float() ?
> 4. Is there a better way of accomplishing this task?
Possibly. If you are using wxPython there is a timer (wx.Timer) in there
that will fire an event (EVT_TIMER) after a suitable delay. This moves
the timed event into your main processing code rather than having it in
a thread. That might be easier. You can certainly start/stop the timer.
You can recreate the timer with a new value after stopping. You can
reuse the same variable name to store the timer.
HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list