Tkinter problem in sizing a frame

Matthew Dixon Cowles matt at mondoinfo.com
Fri Jun 29 16:00:48 EDT 2001


On Fri, 29 Jun 2001 11:04:45 -0400, Joe Potter <jm7potter at hotmail.com>
wrote:

>In the following code (adopted from "Python and Tkinter Programming")
>I find that I can set the minimum size for the root widget. However,
>I can not seem to tell Tk that I want two sub-frames each of which I
>want to take up half the parent frame.  All I get is two sub-frames
>that take up as much room as need to display the label in each.

Joe,
You were very close. The problem was the fill and expand are options
to the packer, not the widgets themselves. (I don't know why the
widgets don't complain that they don't understand those options.)  I
think this will do what you want:

from Tkinter import *

root = Tk()
root.title('Frame Size')
root.geometry("600x300")

# Dont really need this frame f = Frame(root)
xf = Frame(root, relief=GROOVE, borderwidth=5)
jf = Frame(root, relief=GROOVE, borderwidth=5)
  
Label(xf, text="You shot him!").pack(side=LEFT, pady=10)
Label(jf, text='heck if I know !??').pack(side=LEFT, padx=10)

jf.pack(side=TOP,fill=Y,expand=1)
xf.pack(side=BOTTOM,fill=Y,expand=1)
#f.pack()

root.mainloop()

Regards,
Matt



More information about the Python-list mailing list