[Tutor] Tkinter idiosyncracies?

Wayne srilyk at gmail.com
Fri Jun 19 23:41:27 CEST 2009

I'm having some problems with Tkinter doing its own thing (or not) when I
try to time events.

for instance:

import time
import Tkinter as tk

def funky():

root = tk.Tk()
lbl = tk.Label(text = "Click the button to see weirdness")
btn = tk.Button(text='Click me', command=funky)

I'd expect that upon clicking the button the text of the label would change
to 'Foo', then it would wait for 4 seconds, and then the text would change
to 'Bar'. It doesn't do this - instead, it waits for 4 seconds, and then the
text changes to foo, then bar, almost too fast to see. A similar thing
happens (or the exact same) if you replace funky with this definition:

def funky():
lbl.after(4000, lbl.config(text='Bar'))

Am I missing something essential here? Or is this a bug that nobody has
encountered yet?

I appreciate any help!
To be considered stupid and to be told so is more painful than being called
gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness,
every vice, has found its defenders, its rhetoric, its ennoblement and
exaltation, but stupidity hasn’t. - Primo Levi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090619/7d8cf420/attachment.htm>

More information about the Tutor mailing list