Here is a small example for using the form geometry manager, maybe it will be useful for someone. I used -padleft to stick with the subject of the thread but -padx will do the same in this case.
#!/usr/bin/perl use strict; use warnings; use Tk; use Tk::widgets qw{ LabFrame }; my $main = MainWindow->new; #--- Frame 1 my $frame1 = $main->LabFrame( -foreground => 'blue', -label => 'Frame 1', -labelside => 'acrosstop', ); $frame1->grid( $frame1, -row => 0, -column => 0, -ipadx => 3, -ipady => 3, ); #-- column1 my $lcolumn1 = $frame1->Label( -text => 'Label 1', ); $lcolumn1->form( -left => [ %0, 0 ], -top => [ %0, 0 ], -padleft => 5, ); my $ecolumn1 = $frame1->Entry( -width => 15, ); $ecolumn1->form( -top => [ '&', $lcolumn1, 0 ], -left => [ %0, 60 ], ); #-- column2 my $lcolumn2 = $frame1->Label( -text => 'Label 2', ); $lcolumn2->form( -top => [ $lcolumn1, 8 ], -left => [ %0, 0 ], -padleft => 5, ); my $ecolumn2 = $frame1->Entry( -width => 35, ); $ecolumn2->form( -top => [ '&', $lcolumn2, 0 ], -left => [ %0, 60 ], ); #-- column3 my $lcolumn3 = $frame1->Label( -text => 'Label 3', ); $lcolumn3->form( -top => [ $lcolumn2, 8 ], -left => [ %0, 0 ], -padleft => 5, ); my $ecolumn3 = $frame1->Entry( -width => 10, ); $ecolumn3->form( -top => [ '&', $lcolumn3, 0 ], -left => [ %0, 60 ], ); #-+ column4 my $ecolumn4 = $frame1->Entry( -width => 10, ); $ecolumn4->form( -top => [ '&', $lcolumn3 ], -right => [ %100, -6 ], ); my $lcolumn4 = $frame1->Label( -text => 'Label 4', ); $lcolumn4->form( -top => [ '&', $lcolumn3, 0 ], -right => [ $ecolumn4, -10 ], -padleft => 5, ); MainLoop;
The advantage of form manager is that the positioning of the widgets is precise.
You are right, it has resizing problems, but I see no other drawbacks. The spring option(s) would be a nice feature but it doesn't work unfortunately, I wish I could implement them but:
"I'm not really a 'programmer', but I play one on earth."Best regards to all Monks, Stefan :-)
In reply to Re^5: Perl/Tk padding only on one side
by stefbv
in thread Perl/Tk padding only on one side
by Dirk80
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |