#!/apps/perl/bin/perl use strict; use warnings; use Tk; use Tk::Adjuster; use Tk::ROText; my $mw = MainWindow->new(-width=>1500,-height=>650); $mw->packPropagate(0); my $topFrame = $mw->Frame(-relief => 'groove', -borderwidth => 2)-> pack(-side => 'top', -anchor => 'n', -fill => 'x'); my $searchFrame = $topFrame->Frame()-> pack(-side => 'left', -anchor => 'w', -padx => 8, -pady => 3); my $list = $mw->Scrolled("Listbox", -scrollbars => 'se', -selectmode => 'single')-> pack(-side => 'left', -padx => 3, -expand => 1, -fill => 'both', -anchor => 'w'); my $RO_text = $mw->Scrolled("ROText", -scrollbars => 'se', -wrap => 'word')-> pack(-side => 'left', -anchor => 'w', -fill => 'both', -expand => 1); my $adjuster = $mw->Adjuster()->packAfter($list, -side => 'left'); my $searchType; my @searchOptions = ( 'list_and_data', 'list_only' ); $topFrame->Optionmenu( -variable => \$searchType, -options => \@searchOptions, -command => [ \&changeSearchType, \$searchFrame, \$list] )-> pack(-side => 'right', -anchor => 'w', -padx => 5, ipadx => 3); $topFrame->Label(-text => 'Search Type:')->pack(-side => 'right', -anchor => 'w'); MainLoop; sub changeSearchType { if( $searchType eq 'list_only' ) { $RO_text->packForget; $adjuster->packForget; $list->pack(-side => 'left', -expand => 1, -fill => 'both', -anchor => 'w'); my @results = ("apple","banana","orange"); $list->delete(0,'end'); $list->insert('end',\@results); } else { $adjuster->packAfter($list, -side => 'left'); $RO_text->pack(-side => 'left', -expand => 1, -fill => 'both', -anchor => 'w'); my @results = ("apple","banana","orange"); $list->delete(0,'end'); $list->insert('end',\@results); $RO_text->delete('1.0','end'); $RO_text->insert('end',"These are examples of fruit"); } } 1;