On Mon, 7 Nov 2005, Double Six wrote:
> 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,
sys.exit() will raise a SystemExit exception when it's called, so the
program is doing what you think it's doing. However, it looks like the
mainloop() code from Tkinter doesn't expect to see that SystemExit.
You probably want to call the quit() method of the graphical widgets
instead: that'll get us out of the mainloop().
http://www.pythonware.com/library/tkinter/introduction/x9374-event-processing.htm
Best of wishes!
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor