In the main window I want two widgets, a Tree/HList on the left and a Frame on the right which will have other widgets in it.
This is what I want to happen:
Firstly the HList on the left should be scrollable, -Scrolled doesn't seem to work?
When a node in the tree is selected, it generates some widgets in the frame on the right displaying some kind of information. An example in Windows could be Explorer or the Admin tools.
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;
}
my $CalTreeScrollBarY = $leftFrame->Scrollbar();
my $CalTreeScrollBarX = $leftFrame->Scrollbar(-orient=>"horiz");
$CalTree = $leftFrame->Tree(-yscrollcommand=>['set',$CalTreeScrollBarY],
-xscrollcommand=>['set',$CalTreeScrollBarX],);
$CalTreeScrollBarY->configure(-command=> [yview=>$CalTree]);
$CalTreeScrollBarX->configure(-command=> [xview=>$CalTree]);
$CalTreeScrollBarX->pack(-side=>"bottom",-fill=>"x");
$CalTree->pack(-side=>"left",-fill=>"both");
$CalTreeScrollBarY->pack(-side=>"left",-fill=>"y");
perlmonks.org content © perlmonks.org and Anonymous Monk, davidj, eserte, gri6507, zentara
prlmnks.org © 2006 edmund von der burg (eccles & toad)
v 0.03