[Tutor] pack

Shi Mu samrobertsmith at gmail.com
Sat Nov 5 22:57:47 CET 2005


when I clicked 'quit' button,
there is no response. I want to close the interface by clicking 'x',
the interface could not be closed.
i had to close PYTHONWIN to get out of the program.


On 11/5/05, Alan Gauld <alan.gauld at freenet.co.uk> wrote:
> > Why the button of the following code does not work? Thanks!
>
> The program works perfectly for me.
> Which button do you think is not working?
>
> If its the Hello one where do you expect to see the output?
> print always prints to stdout so you need to look in the
> console window not on the GUI.
>
> But otherwise the program worked without modification for me.
>
> HTH,
>
> Alan G.
>
> --------------------------
> from Tkinter import *
>
> class App:
>
>    def __init__(self, master):
>
>        frame = Frame(master)
>        frame.pack()
>
>        self.button = Button(frame, text="QUIT", fg="red",
> command=frame.quit)
>        self.button.pack(side=LEFT)
>
>        self.hi_there = Button(frame, text="Hello", command=self.say_hi)
>        self.hi_there.pack(side=LEFT)
>
>    def say_hi(self):
>        print "hi there, everyone!"
>
> root = Tk()
>
> app = App(root)
>
> root.mainloop()
>
>
> On 11/4/05, Hugo González Monteverde <hugonz-lists at h-lab.net> wrote:
> > pack is a method of Tkinter widget that needs to be called in order to
> > have it displayed with the current geometry manager(which per default is
> >  the pack method)
> >
> > A geometry manager is just a way for arranging widgets into a window.
> > Another geometry manager is "grid"
> >
> > If you don't specify anything, the widget will simply not be displayed..
> > see here:
> >
> > http://effbot.org/tkinterbook/pack.htm
> >
> >
> > Hugo
> >
> > Shi Mu wrote:
> > > what does pack mean in the following code?
> > >
> > > # File: hello1.py
> > >
> > > from Tkinter import *
> > >
> > > root = Tk()
> > >
> > > w = Label(root, text="Hello, world!")
> > > w.pack()
> > >
> > > root.mainloop()
> > > _______________________________________________
> > > Tutor maillist  -  Tutor at python.org
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> >
>
>
>


More information about the Tutor mailing list