http://www.perlmonks.org?node_id=1000582


in reply to Re^2: tk positioning of widgets
in thread tk positioning of widgets

OK, I guess a picture is worth apx 1,000 words

:D So first, words which don't paint a picture, and now, a picture of what you're able to accomplish by yourself?

before (multi line)  perl -MTk  -MTk::WidgetDump  -e " $mw = tkinit; for(0..3){ $f = $mw->Frame(-bg => (qw/ red green blue orange /)[$_] )->pack(qw/-expand 1 -fill both /); $l = $f->Label(-text => qq/T$_/ ); $t = $f->Entry(-text => qq/E$_/); $_->pack(qw/-anchor nw /) for $l, $t; } $mw->WidgetDump; MainLoop "

after (same line)  perl -MTk  -MTk::WidgetDump  -e " $mw = tkinit; for(0..3){ $f = $mw->Frame(-bg => (qw/ red green blue orange /)[$_] )->pack(qw/-expand 1 -fill both /); $l = $f->Label(-text => qq/T$_/ ); $t = $f->Entry(-text => qq/E$_/); $_->pack(qw/-anchor nw -side left /) for $l, $t; } $mw->WidgetDump; MainLoop "

after (same line, one stretchy )  perl -MTk  -MTk::WidgetDump  -e " $mw = tkinit; for(0..3){ $f = $mw->Frame(-bg => (qw/ red green blue orange /)[$_] )->pack(qw/-expand 1 -fill both /); $l = $f->Label(-text => qq/T$_/ ); $t = $f->Entry(-text => qq/E$_/); $l->pack(qw/-anchor nw -side left /); $t->pack(qw/-anchor nw -side left -fill x -expand 1 /); } $mw->WidgetDump; MainLoop "

grid alternative (grid is tricky ) perl -MTk  -MTk::WidgetDump  -e " $mw = tkinit; $f = $mw->Frame(qw/-bg red/)->pack(qw/-expand 1 -fill both /); for(0..3){ $l = $f->Label(-text => qq/T$_/ ); $t = $f->Entry(-text => qq/E$_/); $l->grid(-row => $_, qw/ -column 1 /); $t->grid(-row => $_, qw/ -column 2 -sticky news /);  } $f->Label()->grid(qw/ -row 4 -column 2 -sticky news /);  $f->gridColumnconfigure ( 2, -weight=>1); $f->gridRowconfigure ( 4, -weight=>1); $mw->WidgetDump; MainLoop "