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

use Perl Log In

Log In

[ Create a new account ]

TorgoX (1933)


"Il est beau comme la retractilité des serres des oiseaux rapaces [...] et surtout, comme la rencontre fortuite sur une table de dissection d'une machine à coudre et d'un parapluie !" -- Lautréamont

Journal of TorgoX (1933)

Wednesday April 09, 2003
10:50 PM

In Tk Hell

[ #11565 ]
Dear All,

I am bewildered by Tk -- in general, but also with this specific problem:

So I make some widgets. If I change that if(1) to if(0), and just throw them into the mainwindow, all is well and the window magically appears sized to the right size.

But since I want to be able to deal with cases where there are too many widgets for the window to even fit the screen, I use a Pane object (so make the if(0) an if(1)), I have a new problem: the window starts too small. Sure, I can resize it manually. But how do I make its initial size be the right size, if possible?

Tk is making me sad!

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.
      • Wow! What a funny happenstance of your comment and the random (as in I Ching) Larry Wall quote that I was just served up:

        What about WRITING it first and rationalizing it afterwords? :-)

        --Larry Wall in <8162@jpl-devvax.JPL.NASA.GOV>

      • 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(