Tkinter and IDE's

Don Arnold darnold02 at sprynet.com
Wed Nov 21 07:11:33 EST 2001


Removing the root.mainloop() call does work, although Lutz specifically says
you need it. I didn't realize he must only be referring to standalone
Tkinter apps.

Thanks for the response,
Don


On 20-Nov-2001, Prabhu Ramachandran <prabhu at aero.iitm.ernet.in> wrote:

> >>>>> "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