[Pythonmac-SIG] after
Bob Ippolito
bob at redivi.com
Fri Mar 26 08:53:57 EST 2004
On Mar 26, 2004, at 7:47 AM, Philippe de Rochambeau wrote:
> Hello,
>
> the following tcl/tk code displays a window, then closes it while
> exiting:
>
> #!/usr/bin/wish
>
> button .hello -text Hello \
> -command { puts stdout "Hello World!" }
> pack .hello -padx 20 -pady 20
>
> after 3000 destroy .
>
> The equivalent python/tkinter does not work. Any idea why?
>
> #!/usr/bin/python
>
> from Tkinter import *
>
> def hello():
> print "Hello World!"
>
> root = Tk()
> Button(root, text='Hello', command=hello).\
> pack(padx=20, pady=20)
> root.after(3000, root.destroy())
> root.mainloop()
>
> # Result : macpython icon appears in Dock for
> # several seconds, then quits
I dunno, but if you take out the "root.after(3000, root.destroy())" it
works about as well as you would expect. BTW, you probably should
learn another GUI framework, Tcl/Tk is pretty buggy on OS X.
-bob
More information about the Pythonmac-SIG
mailing list