pack() and the division of vertical space

christopherlmarshall at yahoo.com christopherlmarshall at yahoo.com
Thu May 31 13:45:04 EDT 2007


I am trying to figure out how to stack two widgets in a frame
vertically so that they both expand horizontally and during vertical
expansion, the top one sticks to the top of the frame and the bottom
one consumes the remaining vertical space.  I thought this would do it
but it doesn't.  What am I missing?

from Tkinter import *

class AFrame(Frame):
   def __init__(self,master,**config):
      Frame.__init__(self,master,config)
      size=50
      self.l1= Label(text="abc",relief="groove")
      self.l1.pack(side=TOP,expand=YES,fill=X,anchor=N)
      self.l2= Label(text="abc",relief="groove")
      self.l2.pack(side=TOP,expand=YES,fill=BOTH)

af= AFrame(None)
af.pack(side=TOP,expand=YES,fill=BOTH)
mainloop()




More information about the Python-list mailing list