[Tutor] Error message with testing Tkinter

Double Six doublesix at ureach.com
Mon Nov 7 22:11:16 CET 2005


Hi,

I'm learning Tkinter with the following code on Mac OS X 10.4:

from Tkinter import *
from sys import stdout, exit
widget = Button(None, text = 'Hello?', command=(lambda:
stdout.write('Hello?\n') or exit()))
widget.pack()
widget.mainloop()

I do successfully get a GUI with a button, but the problem is if
I click the button, the GUI window hangs there with the
following message message in the console:

Hello?

Traceback (most recent call last):
  File "/Users/gangc/Python_Scripting/test.py", line 7, in
-toplevel-
    widget.mainloop()
  File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk/Tkinter.py",
line 965, in mainloop
    self.tk.mainloop(n)
  File
"/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk/Tkinter.py",
line 1347, in __call__
    raise SystemExit, msg
SystemExit

What am I missing?

Any help will be highly appreciated,
Joe

________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag


More information about the Tutor mailing list