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

Hi Monks
I'm using the next code
my $log = MainWindow->new(title=>"Who is logged on which tester"); my $log1 = $log -> Frame; $listbox = $log1->Scrolled("Listbox", "-font" => 14, "-width" => 51, "-height" => 37, "-background" => 'lightgreen'); foreach $n (@output){ $listbox-> insert('end',"$n");} $listbox -> pack(-fill => 'both',-expand => 1); $logU=$log1->Frame; $logU->Button( -text => 'Refresh', -background => 'lightgreen', -activebackground => '#0000ff', -activeforeground => '#80ffff', -command => sub{$Refr = 1;$log -> destroy;})->pack(-side => 'l +eft',qw/-ipadx 4 -pady 2/ ,-expand => 1); $logU->Button( -text => 'OK', -background => 'lightgreen', -activebackground => '#0000ff', -activeforeground => '#80ffff', -command => \&exit)->pack(-side => 'right',qw/-ipadx 14 -pady +2/,-expand => 1); $logU->pack(-fill=>'both',-expand=>1,-side=>'bottom'); $log1 -> pack(-fill =>'both',-expand => 1); $log->withdraw; $log->update; my $xpos = int(($log->screenwidth - $log->width ) / 2); my $ypos = int(($log->screenheight - $log->height) / 3);#upper thi +rd instead of middle $log->geometry("+$xpos+$ypos"); $log->deiconify; # Show the window again $log-> bind ('<Key-Return>','destroy'); $log-> bind ('<Key-Escape>','destroy'); $log->protocol('WM_DELETE_WINDOW',sub {$log->destroy;X_pressed();s +leep(2);exit;}); MainLoop;

when I shorten the window's hight, the first frame to be gone is the bottons frame "logU".
I want that frame to be the last to fold.
I actually want the upper frame to fold and use the scrollbar before the lower frame is folded.

pelase advise,
Thanks,
Moked

Replies are listed 'Best First'.
Re: tk folding frame
by zentara (Cardinal) on Aug 13, 2008 at 15:36 UTC
    This is probably your best bet. Make a Scrolled Pane to hold the Listbox, and make a bottom frame set to -fill=>'x', -expand =>0, and the buttons are too. It's not perfect, if you make it too small, everything gets crushed.
    #!/usr/bin/perl use warnings; use Tk; use Tk::Pane; my @output = (1..100); my $log = MainWindow->new( title => "Who is logged on which tester" ); $log->geometry('125x150'); # first pack a scrolled Pane then a bottom frame my $spane = $log->Scrolled('Pane', -scrollbars => 'osoe', -bg => 'blue', )->pack(-expand=>1,-fill=>'both'); #let the scrolled Pane handle the listbox scrolling $listbox = $spane->Listbox( "-font" => 14, "-width" => 51, "-height" => 27, "-background" => 'lightgreen' )->pack(-expand => 1, -fill => 'both'); foreach $n ( @output ) { $listbox->insert( 'end', "$n" ); } my $logU = $log->Frame->pack( -fill => 'x', -expand => 0 ); $logU->Button( -text => 'Refresh', -background => 'lightgreen', -activebackground => '#0000ff', -activeforeground => '#80ffff', -command => sub { $Refr = 1; $log->destroy; } )->pack( -side => 'left', qw/-ipadx 4 -pady 2/, -expand => 0 ); $logU->Button( -text => 'OK', -background => 'lightgreen', -activebackground => '#0000ff', -activeforeground => '#80ffff', -command => \&exit )->pack( -side => 'right', qw/-ipadx 14 -pady 2/, -expand => 0 ); MainLoop;

    I'm not really a human, but I play one on earth Remember How Lucky You Are