| 1 |
#!/usr/local/bin/perl |
| 2 |
use Tk; |
| 3 |
use Tk::TiedListbox; |
| 4 |
|
| 5 |
my $top = MainWindow->new; |
| 6 |
my $f = $top->Frame->pack(-expand => 'yes', -fill => 'both'); |
| 7 |
my $l1 = $f->ScrlListbox(-relief => 'flat', |
| 8 |
-exportselection => 0, |
| 9 |
-selectmode => 'extended',-height => 20); |
| 10 |
my $l2 = $f->ScrlListbox(-relief => 'flat', |
| 11 |
-exportselection => 0, |
| 12 |
-selectmode => 'extended',-height => 10); |
| 13 |
my $l3 = $f->ScrlListbox(-relief => 'flat', |
| 14 |
-exportselection => 0, |
| 15 |
-selectmode => 'extended',-height => 20, |
| 16 |
# -font => 'clb6x10' |
| 17 |
); |
| 18 |
my $bv1,$bv2; |
| 19 |
my $b1 = $f->Checkbutton(-text => 'tie selection', |
| 20 |
-variable => \$bv1, |
| 21 |
-command => [\&set_tie,\$bv1,\$bv2]); |
| 22 |
my $b2 = $f->Checkbutton(-text => 'tie scroll', |
| 23 |
-variable => \$bv2, |
| 24 |
-command => [\&set_tie,\$bv1,\$bv2]); |
| 25 |
$b1->pack(-side => bottom); |
| 26 |
$b2->pack(-side => bottom); |
| 27 |
$l1->pack(-expand => 'yes', -side => 'left'); |
| 28 |
$l2->pack(-expand => 'yes', -side => 'left'); |
| 29 |
$l3->pack(-expand => 'yes', -side => 'left'); |
| 30 |
|
| 31 |
my $id; |
| 32 |
foreach $id (0..300){ |
| 33 |
$l1->insert('end', $id) if $id<100; |
| 34 |
$l2->insert('end', $id); |
| 35 |
$l3->insert('end', $id); |
| 36 |
} |
| 37 |
|
| 38 |
$b1->invoke; |
| 39 |
$b2->invoke; |
| 40 |
|
| 41 |
MainLoop(); |
| 42 |
|
| 43 |
sub set_tie { |
| 44 |
my($b1,$b2)=@_; |
| 45 |
my($x1,$x2,$x3)=map($_->Subwidget('scrolled'),$l1,$l2,$l3); |
| 46 |
$x1->tie('all', [$x2,$x3]),return if($$b1 && $$b2); |
| 47 |
$x1->tie('selection',[$x2,$x3]),return if($$b1); |
| 48 |
$x1->tie('scroll', [$x2,$x3]),return if($$b2); |
| 49 |
$x1->untie,$x2->untie,$x3->untie; |
| 50 |
} |
| 51 |
|
| 52 |
|