Tk mainloop()

Jeff Epler jepler at unpythonic.net
Sun Jul 20 08:48:23 EDT 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)
t.mainloop()





More information about the Python-list mailing list