R
Ronny
I posted the question below some time ago, but did not receive any
comment,
so I will try it a second time. Actually I was surprised that it seems
to be a
much more difficult problem than I first thought. I short, I would like
to align
a bunch of fields in a form, so that each field starts to on the left,
instead of
being centered. In detail, the problem is this:
My window should consists of several "lines". Each line consists of
- a checkbox
- a label
- an entry field
for example (the X denoting a checkbox):
X LABEL1 entry field for user data
X LABEL2 another entry field where the user can enter some value
X LABEL3 a third entry field
I used the following approach (which works basically well - but see
below):
# Code for adding one line to the root window:
frame=TkFrame.new(root)
frame.pack()
check=TkCheckButton.new(frame).pack("side" => "left")
label=TkLabel.new(frame) { text "...." }
label.pack("side" => "left")
entry=TkEntry.new(frame).pack("side" => "left")
entry.value="...."
Now the problem is that since the label texts and initial values
for each line are of different size, and since by default the
frame is centered within the root window, the check buttons
turn out to be not lined up one below the other, which gives
an ugly look, like this:
X LABEL1 entry field for user data
X LABEL2 another entry field where the user can enter some value
X LABEL3 a third entry field
I.e. the fields in the frames are centered instead of being left
justified.
I tried to remedy this by changing the first statement to
frame=TkFrame.new(root) { justify 'left' }
but this does not work, because "justify" is not valid for a TkFrame.
How do I get a left-justified layout?
Ronald
comment,
so I will try it a second time. Actually I was surprised that it seems
to be a
much more difficult problem than I first thought. I short, I would like
to align
a bunch of fields in a form, so that each field starts to on the left,
instead of
being centered. In detail, the problem is this:
My window should consists of several "lines". Each line consists of
- a checkbox
- a label
- an entry field
for example (the X denoting a checkbox):
X LABEL1 entry field for user data
X LABEL2 another entry field where the user can enter some value
X LABEL3 a third entry field
I used the following approach (which works basically well - but see
below):
# Code for adding one line to the root window:
frame=TkFrame.new(root)
frame.pack()
check=TkCheckButton.new(frame).pack("side" => "left")
label=TkLabel.new(frame) { text "...." }
label.pack("side" => "left")
entry=TkEntry.new(frame).pack("side" => "left")
entry.value="...."
Now the problem is that since the label texts and initial values
for each line are of different size, and since by default the
frame is centered within the root window, the check buttons
turn out to be not lined up one below the other, which gives
an ugly look, like this:
X LABEL1 entry field for user data
X LABEL2 another entry field where the user can enter some value
X LABEL3 a third entry field
I.e. the fields in the frames are centered instead of being left
justified.
I tried to remedy this by changing the first statement to
frame=TkFrame.new(root) { justify 'left' }
but this does not work, because "justify" is not valid for a TkFrame.
How do I get a left-justified layout?
Ronald