in reply to Re^2: Perl/Tk padding only on one side
in thread Perl/Tk padding only on one side

The form geometry manager has this options both on GNU/Linux and win32. :)

Replies are listed 'Best First'.
Re^4: Perl/Tk padding only on one side
by zentara (Cardinal) on Nov 17, 2009 at 12:11 UTC
    ...u learn something new everyday..... :-) .... form actually looks pretty nice as far as options go....i wonder if it will replace pack?....if not why not?..... i mean everyone just started using pack after Nick Ing Simmons (R.I.P.) wrote his book and recommending sticking with pack... any drawbacks to using form?..... like resizing problems?

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku

      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 :-)
Re^4: Perl/Tk padding only on one side
by Dirk80 (Pilgrim) on Nov 18, 2009 at 14:23 UTC

    Thank you for your answers. The form manager can solve my problems.

    It was a very simple program. I have a parent frame. In this frame I put two widgets.

    The first widget shall start directly at the top of the parent frame. Then there shall be a gap of 5 pixels. The second widget shall be the next.

    Greetings Dirk