best way to create a timer

Rhamphoryncus rhamph at
Sat Jun 14 19:10:10 CEST 2008

On Jun 12, 11:42 pm, Alexnb <alexnbr... at> wrote:
> 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. 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.

Tkinter makes a big difference here.  Like most (all?) event loops, it
provides a way to call a function after a specified amount of time.

Here's two pages I found:

Note that it only fires once.  If you want it to fire again you're
callback will have to setup another timer.

More information about the Python-list mailing list