Can I set up a timed callback without Tkinter or twisted or something?

Scott David Daniels scott.daniels at acm.org
Sat Oct 14 12:08:43 EDT 2006


Hendrik van Rooyen wrote:
> I want to do the equivalent of the after thingy in tkinter - setting up in
> effect a timed call back.
> 
> My use case is as a "supervisory" timer - I want to set up an alarm, which I
> want to cancel if the expected occurrence occurs - but its not a GUI app.

Use a thread that uses something like:
       def action():
           sleep(50)
           if not canceled:
               callback(foo)
as its action.

The callback ill be in another thread, but ....  Look up threading for
more details.


--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list