in reply to Perl/Tk Associating HLists with other widgets

I modified the following from the tk::hlist manpage.

I admit that it is a weak hack, but it will give you an idea of how to accomplish what you want.
In sub pw() it simply destroys the current label widget (if it exists) and puts a new label widget in the frame. I could have just reconfigured the widget, but I did it this way to show a way to remove one widget from the frame and create a new one.
Run it, follow the code, and you will get the idea

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; }

Hope this helps,

davidj