Dear tkinter-discuss,
I'm trying to make a user interface like the following:
::::::::::::::::::::::::::::::::::::::::::::
: XXXXXXXXXXXXXX : <- a Label
:[ <-- expands ][ expands --> ]: <- 2 Entries
:[ <-- expands ][ expands --> ]: <- 2 more Entries
: :
: (empty space expands :
: downward) :
:..........................................:
Pseudo-code (full code at end of document):
toplevel
"XXXXXXXXXXXXXX" label anchor=n pack
frame expand=1 fill=x anchor=n pack
entry expand=1 fill=x anchor=n lpack
entry expand=1 fill=x anchor=n lpack
frame expand=1 fill=x anchor=n pack
entry expand=1 fill=x anchor=n lpack
entry expand=1 fill=x anchor=n lpack
frame expand=1 fill=both anchor=n pack
What I'm finding is this:
1. the label (XXXXXXXXXXXXXX) hugs the top of the window
(GOOD)
2. the top two entries hug the label
(GOOD)
3. the lower two entries space a ways away from the top two entries
(DO NOT WANT)
What I want instead, is that the lower two entries hug the top two
entries.
(More deeply: I want to UNDERSTAND why this is happening like this.
I could use a grid and that would solve this problem, but I want to
have facility with the packer, too.)
I've tried changing around the values a bunch, but I just don't have
any luck getting this to work.
My assumption (that seems to be flawed) is that when I set expand=1,
that if it says "fill=x", then that means that it will ONLY expand
horizontally. But it seems to be expanding in both directions.
Thoughts? Insights?
== Full Example (Python 3.2) ==
from tkinter import *
t = Toplevel()
lbl = Label(t, text="XXXXXXXXXXX")
lbl.pack(side=TOP, anchor=N)
f1 = Frame(t)
f1.pack(side=TOP, expand=1, fill=X, anchor=N)
e11 = Entry(f1)
e11.pack(side=LEFT, expand=1, fill=X, anchor=N)
e12 = Entry(f1)
e12.pack(side=LEFT, expand=1, fill=X, anchor=N)
f2 = Frame(t)
f2.pack(side=TOP, expand=1, fill=X, anchor=N)
e21 = Entry(f2)
e21.pack(side=LEFT, expand=1, fill=X, anchor=N)
e22 = Entry(f2)
e22.pack(side=LEFT, expand=1, fill=X, anchor=N)
# This last one seems to do nothing.
# My hope was that it would somehow "pressure" f2 higher, but nope.
f3 = Frame(t)
f3.pack(side=TOP, expand=1, fill=X, anchor=N)
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss