Tkinter and IDE's

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Tue Nov 20 23:48:44 EST 2001


>>>>> "DA" == Don Arnold <darnold02 at sprynet.com> writes:

    DA> def quit(): print "Hello, I must be going" # import sys #
    DA> sys.exit() root.quit()

    DA> root = Tk() widget = Button(root, text="Hello, event world",
    DA> command = quit) widget.pack() root.mainloop()

Well, what happens when you remove the root.mainloop()?

Your other errors will occur simply because of the way you have
defined quit.  Change it like so:

>>> from Tkinter import *
>>> root = Tk()
>>> def quit():
...   print "Hello, I must be going"
...   root.destroy()
... 
>>> widget = Button(root, text="Hello, event world", command = quit)
>>> widget.pack()
>>> # click on button
>>> Hello, I must be going

This should definitely work. 

prabhu




More information about the Python-list mailing list