File: testlistbox

package info (click to toggle)
perl-tk 1:804.033-2
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 34,724 kB
  • ctags: 37,174
  • sloc: ansic: 349,541; perl: 52,192; sh: 17,904; makefile: 5,732; asm: 3,565; ada: 1,681; pascal: 1,089; cpp: 1,006; yacc: 883; cs: 879
file content (52 lines) | stat: -rwxr-xr-x 1,675 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/local/bin/perl
use Tk;
use Tk::TiedListbox;

my $top = MainWindow->new;
my $f = $top->Frame->pack(-expand => 'yes', -fill => 'both');
my $l1 = $f->ScrlListbox(-relief => 'flat',
                         -exportselection => 0,
                         -selectmode => 'extended',-height => 20);
my $l2 = $f->ScrlListbox(-relief => 'flat',
                         -exportselection => 0,
                         -selectmode => 'extended',-height => 10);
my $l3 = $f->ScrlListbox(-relief => 'flat',
                         -exportselection => 0,
                         -selectmode => 'extended',-height => 20,
                         # -font => 'clb6x10'
                         );
my $bv1,$bv2;
my $b1 = $f->Checkbutton(-text => 'tie selection',
                         -variable => \$bv1,
                         -command => [\&set_tie,\$bv1,\$bv2]);
my $b2 = $f->Checkbutton(-text => 'tie scroll',
                         -variable => \$bv2,
                         -command => [\&set_tie,\$bv1,\$bv2]);
$b1->pack(-side => bottom);
$b2->pack(-side => bottom);
$l1->pack(-expand => 'yes', -side => 'left');
$l2->pack(-expand => 'yes', -side => 'left');
$l3->pack(-expand => 'yes', -side => 'left');

my $id;
foreach $id (0..300){
  $l1->insert('end', $id) if $id<100;
  $l2->insert('end', $id);
  $l3->insert('end', $id);
}

$b1->invoke;
$b2->invoke;

MainLoop();

sub set_tie {
  my($b1,$b2)=@_;
  my($x1,$x2,$x3)=map($_->Subwidget('scrolled'),$l1,$l2,$l3);
  $x1->tie('all',      [$x2,$x3]),return if($$b1 && $$b2);
  $x1->tie('selection',[$x2,$x3]),return if($$b1);
  $x1->tie('scroll',   [$x2,$x3]),return if($$b2);
  $x1->untie,$x2->untie,$x3->untie;
}