Inappropriate Packing

sragsdale at my-deja.com sragsdale at my-deja.com
Thu Dec 2 14:52:16 EST 1999


I must be misunderstanding something about the arguments given to
pack().  I'm trying to create an application where there's a menu bar at
the top, a tool bar at the bottom, and a frame in the middle that takes
up all remaining space.  When the following app is resized, the middle
panel doesn't take up as much as it should and the bottom menu bar
consumes too much.  What's going on?

##################################################################
inter import *

class App(Frame):
    def __init__(self,parent):
        Frame.__init__(self,parent)

        self.makeMenuBar()

        mf = Frame(self,relief=RAISED,bd=2)
        mf.pack(expand=YES,fill=BOTH)
        Label(mf,text="top of frame").pack(side=TOP)
        Label(mf,text="bottom of frame").pack(side=TOP)

        self.makeToolBar()

    # make the menu bar (above)
    def makeMenuBar(self):
        self.menubar = Frame(self, relief=RAISED, bd=2)
        self.menubar.pack(side=TOP, fill=X)
        mbutton = Menubutton(self.menubar, text='File', underline=0)
        mbutton.pack(side=LEFT)
        menu = Menu(mbutton)
        menu.add_command(label="Save", command=None)
        mbutton['menu']=menu

    def makeToolBar(self):
        toolbar = Frame(self, relief=SUNKEN, bd=2)
        toolbar.pack(side=BOTTOM, expand=YES, fill=X)
        Button(toolbar, text='Quit', command=self.quit).pack(side=RIGHT)
        self.message = Label(toolbar)
        self.message.pack(side=LEFT)

bob = App(None)
bob.pack(expand=YES,fill=BOTH)
bob.mainloop()


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list