best way to create a timer/alarm

Gabriel Genellina gagsl-py2 at
Fri Jun 13 09:36:17 CEST 2008

En Fri, 13 Jun 2008 02:42:53 -0300, Alexnb <alexnbryan at> escribió:

> I am wondering what is the best way to create a timer, like an alarm,  
> once it
> reaches a time, it triggers an event. I have a way of doing this but it
> seems like it isn't good at all. If it helps at all I am using a Tkinter,
> but that probably doesn't mean much.

Actually it *is* very important - such things are done in very different  
ways on different GUI libraries.

> The way I was doing it was using a
> while loop, and just saying while current time is not = to trigger time,  
> do
> nothing, and when it is, do event.

Doing so makes your application irresponsive (frozen) until the time  
Use the "after" method; see <>

Gabriel Genellina

More information about the Python-list mailing list