Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • See the geometry() method.
    • Yeah, I've seen the geometry() method -- I don't see how to make it be "just the right size" the way it normally would be without that Pack thingamajigger.
      • Oh, I see what you mean. Here's your code, revamped by me (plus an "exit" button). This work like you want?
        use strict;
        use Tk;
        use Tk::Pane;

        my $main = MainWindow->new;

        my($container, $pane);

        $pane = $main->Scrolled('Pane',
           -scrollbars => 'osoe',
           -sticky     => 'nsew',
           -gridded    => 'y'
        $pane->pack(-fill => 'both', -expand => 1,);

        my $width = 0;
        my $height = 0;

        for(0 .. 10) {
           my $label  = $pane->Label(-text => "Sed ut perspiciatis" );
           my $b2 = $pane->Button(-text => "Hooboy");
           my $b1 = $pane->Button(-text => "Yow!")->grid($label,$b2);

           my $twidth = $b1->reqwidth + $b2->reqwidth + $label->reqwidth;
           $width = $twidth if $twidth > $width;

           $height += $b1->reqheight;

        $pane->pack if $pane;

        my $eb = $main->Button(-text=>"Exit",-command=>sub{exit})->pack;
        $width += $eb->reqwidth;
        $height += $eb->reqheight;


        MainLoo p();