newbie:this program stops responding after pressing quit button

Eric Brunel see.signature at no.spam
Tue Dec 4 11:10:19 EST 2007


On Tue, 04 Dec 2007 14:32:34 +0100, 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( )

While I can't reproduce the problem you have since I'm on an older  
Python/Tkinter version, I'd say these last two lines are the problem: in  
Tkinter, Frame instances are not windows, but generic containers. Creating  
a Frame instance without having a window implicitly creates one, but you  
have to use some Tkinter internals to manipulate it, which is never a good  
idea. I'd replace these two lines with this one:

win = Tk()

which actually create the main window for the application as well as the  
underlying tcl interpreter, required by Tkinter.

Please note this must be done only for the main window, i.e exactly once  
in your application; other ones must be created as Toplevel instances, not  
Tk ones.

> 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( )

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"



More information about the Python-list mailing list