Timer in Tkinter?

moonlite56 at yahoo.com moonlite56 at yahoo.com
Fri Aug 17 05:31:45 CEST 2001


The after method works, but it only updates once. Is there a way for 
it to keep running continously, so that the pet updates over and 
over again?

--------------

Yes, there is. Use the after method:

>>> from Tkinter import *
>>> def printSomething():
...   print "wibble"
... 
>>> root=Tk()
>>> root.after(2000,printSomething)
'after#2'
>>> wibble

The first argument to after is the number of milliseconds to wait and
the second argument is the function to call. For information like 
this
about Tkinter, I recommend Fredrik Lundh's excellent An Introduction
to Tkinter. It's at:

http://www.pythonware.com/library/tkinter/introduction/index.htm

I almost always have a local copy open when I'm doing Tkinter
programming.









More information about the Python-list mailing list