Luc <
[email protected]> wrote:
I am beginning to hate the grid geometry manager.
It is much easier to use to achieve most typicaly GUI layouts than
pack.
Will you please take a look at this code?
https://pastebin.com/iA8SLDMH
I am beginning to hate the grid geometry manager because there are certain size/dimension options that we are supposed to be able to tweak, but when
I tweak them, nothing happens. Grumble.
Because some of them only 'function' when other settings are toggled
on.
I find it very confusing because of this part of the code:
grid $::w.outerframe
grid $::w.outerframe.frame1_row1 -column 0 -row 0 -columnspan 10 -sticky n
grid $::w.outerframe.frame2_row2 -column 0 -row 1 -columnspan 10 -sticky we
grid $::w.outerframe.frame3A_row3_LEFT -column 0 -row 2 -columnspan 1 -sticky we
grid $::w.outerframe.frame3B_row3_RIGHT -column 1 -row 2 -columnspan 9 -sticky we
grid $::w.outerframe.frame4A_row4_LEFT -column 0 -row 3 -columnspan 1 -sticky we
grid $::w.outerframe.frame4B_row4_RIGHT -column 1 -row 3 -columnspan 9 -sticky we
grid $::w.outerframe.frame5_row5 -column 0 -row 4 -columnspan 10 -sticky s
In my poor understanding, the second line (at least, among others) establishes that I want to treat the entire window like it has 10 columns.
That is what you have told grid.
So I expect the "3A" frame (label) to occupy exactly 1/10 of the window's length,
Ah, herein lies the confusion. length != column
9 out of 10 columns does not imply 90% of width (except in the instance
of exactly equal width columns -- but grid does not guarantee exactly
equal width columns). Do not think of columns in grid as anything
other than relative positioning compared to other widgets. Actual
screen width, of any given column, will depend upon the size needed for
any widgets in the cells.
How can I bring that entry widget closer to the label widget, please?
Does this layout match your expectations?:
Note several changes:
1) Got rid of 'eval destroy ...' and made it just 'destroy ...' (no
need for eval here, and in general, for 99% of typical Tcl/Tk
programming, one never need touch 'eval' at all)
2) Removed all the extraneous frames (they were also likely causing you
part of your trouble, because you also have to properly configure each
of them for the final grid to layout properly)
3) Simplified the widget definitions, and caputured the full widget
names in variables for the final 'gridding'.
4) Switched to grid "relative placement" symbols.
5) Dropped the "10 columns" (remember, columns!=length) - you have only
two columns at most in your widget layout, so this new grid has only
two columns.
4) Enabled 'columnconfigure -weight 1' on column 1 (this was the
'setting' you had not yet toggled on, and it is the critical one for
getting many grid layouts to finally 'snap' into shape much of the
time. This is also the 'setting' I alluded to at the beginning of this
post.
--- code ---
package require Tk
package require tile
ttk::style theme use alt
wm withdraw .
destroy [winfo children .]
catch {destroy .manage}
set ::w [toplevel .manage]
wm resizable $::w 1 1
tk appname "W"
wm title $::w "W"
set of [frame $::w.outerframe]
set topLabel [label $of.topLabel -font {Arial 16} -anchor center -text "TITLE" \
-justify center -relief ridge -borderwidth 4]
set 2ndLineLabel [label $of.2ndLineLabel -font {Arial 16} -anchor center \
-text "the presence of some possibly very long text here, it could happen" \
-relief ridge -borderwidth 4]
set leftLabel [label $of.leftLabel -font {Arial 16} -anchor w -text "Input:" \
-background #ffffff -relief ridge -borderwidth 4]
set rightEntry [entry $of.rightEntry -background #ffffff -width 24 -text "type" \
-background #ffffff -relief ridge -borderwidth 4]
$rightEntry insert end "3B RIGHT"
set infoLabel [label $of.infoLabel -background #ffffff -anchor w \
-font {Arial 16} -text