in reply to Perl/Tk Associating HLists with other widgets
use strict; use Tk; use Tk::Label; use Tk::HList; my $mw = MainWindow->new(); my $widget = 0; my $frame = $mw->Frame(); # my $hlist = $mw->HList( #uncomment this line and comment the next + if Scrolled does not work my $hlist = $mw->Scrolled(qw/HList/, -itemtype => 'text', -separator => '/', -selectmode => 'single', -browsecmd => sub { my $file = shift; &pw($file); } ); foreach ( qw(/ /home /home/ioi /home/foo /usr /usr/lib) ) { $hlist->add($_, -text=>$_); } $hlist->pack; $frame->pack; MainLoop; sub pw() { my $txt = shift; $widget->destroy if $widget != 0; $widget = $frame->Label(-text => $txt)->pack; }
|
|---|