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