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.

Full
Abbreviated
Hidden
• #### It's not trigonometry(Score:2)

See the geometry() method.
• #### Re:It's not trigonometry(Score:3, Interesting)

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.
• #### Re:It's not trigonometry(Score:2)

by djberg96 (2603) on 2003.04.10 20:07 (#19026) Journal
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;

\$pane->configure(-width=>\$width,-height=>\$height);

MainLoo p();
• #### Re:It's not trigonometry(Score:2)

oops - get rid of that second pane pack line.
• #### Re:It's not trigonometry(Score:2)

Wow, I thought something like this might be necessary, but 1) I didn't know how to do it, and 2) I kept thinking "wait, shouldn't the geometry manager already be doing this for me, via some switch I can't find?".

But I like your way. It works!