Quit-command not quiting
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Fri Mar 7 10:18:20 EST 2008
En Fri, 07 Mar 2008 12:56:44 -0200, K Viltersten <tmp1 at viltersten.com>
escribi�:
> I entered the code from tkinter.pdf, section
> 2 but for reason, the application doesn't
> close as i press the quit-button.
>
> The wondow itself vanishes if i click the
> cross in the upper-right corner but pressing
> the quit-button only makes it "pressed".
> Then, the program freezes.
How did you run it? From inside IDLE? IDLE itself is written using Tk, and
I think that your mainloop interferes with the one inside it.
If you run your program from the command line it should work fine.
> from Tkinter import *
> class Demo (Frame):
> def __init__ (self, master = None):
> Frame.__init__ (self, master)
> self.grid ()
> self.doLayout ()
> def doLayout (self):
> self.quitButton = Button (
> self,
> text = "Quit",
> command = self.quit)
> self.quitButton.grid ()
>
> d = Demo ()
> d.master.title ("the coolest demo ever")
> d.mainloop ()
There is only one thing I hate more than spaces after a parens: spaces
before it :)
Please read PEP8, about the suggested style for writting Python code.
http://www.python.org/dev/peps/pep-0008/
--
Gabriel Genellina
More information about the Python-list
mailing list