Tk mainloop()

Jeff Epler jepler at
Sun Jul 20 14:48:23 CEST 2003

Use the 'after' method of widgets.  This program increments the counter
in the label about once a second.

from Tkinter import *

def update_and_requeue():
        v.set(v.get() + 1)
        t.after(1000, update_and_requeue)

t = Tk()
v = IntVar(t)
l = Label(t, textvariable=v); l.pack(side="top")
b = Button(t, command=t.destroy, text="Close"); b.pack(side="top")
t.after(1000, update_and_requeue)

More information about the Python-list mailing list