holli has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have this little Tk-App that basically consists of two frames, with a vertical adjuster in between them.
#!/usr/local/bin/perl -w use Tk; use strict; require Tk::TFrame; require Tk::Adjuster; my ( $mw, $frmLeft, $adjMiddle, $frmRight, ); $mw = MainWindow->new(-title => 'foo'); $frmLeft = $mw->TFrame ( label => [-text => 'links'] )->pack (-expand => 1, -fill => "both", -side => 'left'); $adjMiddle = $mw->Adjuster ( -widget => $frmLeft, -side => 'left', -restore => 1, )->pack (-side => 'left', -fill => 'y'); $frmRight = $mw->TFrame ( label => [-text => 'rechts'] )->pack (-expand => 1, -fill => "both", -side => 'right'); MainLoop;
Start the above program and you'll note the two frames are equally wide. If you now maximize the window, you'll notice that the left frame stays small while the right frame grows. That's not what I want. I'd prefer that both frames would grow/shrink relative to the growth of the main window.

I tried catching the "Expose" event and use that to resize the left frame manually, but the -width property for the main window always returns zero.


holli, /regexed monk/

Replies are listed 'Best First'.
Re: Tk::Adjuster, how to keep proportions
by thundergnat (Deacon) on Feb 06, 2006 at 21:05 UTC

    A little kludgy perhaps, but I think this is possibly what you are trying to do...

    Note: the $mw->update before binding the <Configure> is necessary to avoid all the configure events generated during widget construction.

    Update: Added the eventGenerate to load values so maximizing the window will keep the ratio even if the window hasn't been resized first. Also removed unnecessary binding to <ButtonPress-1>.

      Very clever++.

      I'm not really a human, but I play one on earth. flash japh