newbie:this program stops responding after pressing quit button

Michael Speer knome.net at gmail.com
Tue Dec 4 10:29:35 EST 2007


On Dec 4, 2007 8:32 AM, Boris <cybernaut09 at gmail.com> wrote:
> I am using windows vista and python 2.5 .This program stops responding
> after pressing quit button. I am not able to figure the problem out.
> please help.
>
> from Tkinter import *
>
> def greeting( ):
>     print 'Hello stdout world!...'
>
> win = Frame(
>  )
> win.pack( )
> Label(win,  text='Hello container world').pack(side=TOP)
> Button(win, text='Hello', command=greeting).pack(side=LEFT)
> Button(win, text='Quit',  command=win.quit).pack(side=RIGHT)
>
> win.mainloop( )
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

While unfamiliar with the package, I loaded it up to see if I could
help you out.

I loaded Tkinter and ran your code under ubuntu in the interactive
prompt and saw the same result.

The doc for the win.quit function states "Quit the Tcl interpreter.
All widgets will be destroyed." but I certainly don't see that
happening here.  If you really want to quit, try setting the command
for the quit button to sys.exit perhaps?  This left my terminal in a
state I had to `reset` out of but it did kill the program.

Hmm.  Further testing seems to show that it may be a simple matter of
Tkinter only getting rid of windows and things if there are no
references left to them from the python runtime.

Your win.quit won't destroy the window as long as the variable win refers to it.

Load up your interpreter and play with it interactively.  Remember the
dir( object ) command will give a full listing of the attributes of
any given object.  Looking at object.__doc__ will give you the
documentation.  There's probably something in there to hide the window
if that is all you want.

Good luck solving your problem.

Michael Speer
http://michaelspeer.blogspot.com/



More information about the Python-list mailing list