[Tutor] How to enable pausing my timer.py ?
Christian.Wyglendowski at greenville.edu
Wed Jul 7 22:56:31 CEST 2004
> -----Original Message-----
> > I just realized that my stopwatch was really a timer: you set it to
> > after a length of time you enter; it stops and beeps when that time
> is up.
> You could make it even more general purpose buy putting the
> guts of it in a function called say, doAfter()
> def doAfter(t,f):
> ''' t is the time required and f is a function to be executed
> after t expires.'''
> Thus in your current case you would call
> doAfter( t, lambda : winsound.beep(500) )
Which is I believe what the Timer object in the threading module lets
>>> import threading, sys
>>> t = threading.Timer(10, sys.stdout.write, ['Done'])
...(waits for 10 secs)...
Documentation for the threading.Timer object can be found here:
In order to pause one, I think you would need to send the thread a
signal, but that sort of magic is beyond the skill of *this* python hack
;-) Maybe I'll play around with it and see if I can figure it out.
> Alan G.
> Tutor maillist - Tutor at python.org
More information about the Tutor