use strict; use Tk; my $frame; my $text; # 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'); # This works. Comment out 2 "frame" lines and comment in "bind" lines # to see the problem... $frame=$top->Frame(-background=>'blue')->pack(-fill=>'both'); $frame->Label(-text=>'The frame is blue')->pack(-side=>'top'); # This doesn't work... #$list->bind("<>", sub { # $frame=$top->Frame(-background=>'blue')->pack(-fill=>'both'); # $frame->Label(-text=>'The frame is blue')->pack(-side=>'top'); #}); $top->Button(-text=>'Put text into frame', -command=>sub{ if(!$frame){return}; $text->packForget; $text->pack(-in=>$frame); })->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;