Most people have learned to just use a Tk::Pane..... it works better. Try this. You may have to experiment with nesting the Pane into a Frame so the Label dosn't expand too much.
#!/usr/bin/perl use strict; use Tk; require Tk::Pane; my $frame; my $text; my $pane; # Create yellow toplevel window... my $top=MainWindow->new(); $top->configure(-background=>'yellow'); $top->Label(-text=>'Toplevel is yellow')->pack(-side=>'top'); # Create top level listbox... my $list = $top->Scrolled('Listbox', -selectmode=>'single', )->pack(-fill=>'both', -side=>'left'); #create a Pane $pane=$top->Scrolled('Pane', -scrollbars=>'osoe', -background=>'blue'); $list->bind("<<ListboxSelect>>", sub { $pane->pack(-expand=>1, -fill=>'both'); $frame=$pane->Frame(-height=>1)->pack(-side=>'top',-pady=>0); $frame->Label(-text=>'The pane is blue', -height=>1)->pack(-side=>'top',-pady=>0); }); $top->Button(-text=>'Put text into pane', -command=>sub{ if(!$pane){return}; $text->packForget; $text->pack(-in=>$pane); })->pack; $top->Button(-text=>'Take text out of frame', -command=>sub{ $text->packForget; $text->pack(-in=>$top); })->pack; # Create unpacked text window... $text = $top->Scrolled('Text', -wrap=>'none', -background=>'green'); $text->insert('end', 'Green is the text box'); $list->insert( 'end', 'CreateFrame'); MainLoop;
In reply to Re: Strange Tk Frame Behavior
by zentara
in thread Strange Tk Frame Behavior - SOLVED
by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |