#!/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("<>", 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;