| 1 |
#!/usr/local/bin/perl -w |
| 2 |
|
| 3 |
use Tk; |
| 4 |
require Tk::HList; |
| 5 |
|
| 6 |
$mw = MainWindow->new; |
| 7 |
|
| 8 |
my $hl = $mw->Scrolled('HList', -separator => '.', -width => 25, |
| 9 |
-drawbranch => 1, |
| 10 |
-selectmode => 'extended', -columns => 2, |
| 11 |
-indent => 10); |
| 12 |
|
| 13 |
$hl->configure( -command => [ sub |
| 14 |
{ |
| 15 |
my $hl = shift; |
| 16 |
my $ent = shift; |
| 17 |
my $data = $hl->info('data',$ent); |
| 18 |
foreach ($hl,$ent,$data) |
| 19 |
{ |
| 20 |
print ref($_) ? "ref $_\n" : "string $_\n"; |
| 21 |
} |
| 22 |
print "\n"; |
| 23 |
}, $hl |
| 24 |
] |
| 25 |
); |
| 26 |
|
| 27 |
$hl->pack(-expand => 1, -fill => 'both'); |
| 28 |
|
| 29 |
@list = qw(one two three); |
| 30 |
|
| 31 |
my $i = 0; |
| 32 |
foreach my $item (@list) |
| 33 |
{ |
| 34 |
$hl->add($item, -itemtype => 'text', -text => $item, -data => {}); |
| 35 |
my $subitem; |
| 36 |
foreach $subitem (@list) |
| 37 |
{ |
| 38 |
$hl->addchild($item, -itemtype => 'text', -text => $subitem, -data => []); |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
MainLoop; |