Damit man in mehreren Listboxen selektieren kann, muss man die Option -exportselection auf 0 setzen.
Beispiel:
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
#!/usr/bin/perl
use strict;
use warnings 'all';
use Tk;
my $mw = tkinit;
my $tf = $mw->Frame()->pack(qw/-fill both -expand 1/);
my @lb;
push(@lb, $tf->Listbox(-exportselection => 0)->pack(-side => "left"));
push(@lb, $tf->Listbox(-exportselection => 0)->pack(-side => "left"));
push(@lb, $tf->Listbox(-exportselection => 0)->pack(-side => "left"));
foreach (@lb)
{
$_->insert('end',"Test" );
$_->insert('end',"Test1");
$_->insert('end',"Test2");
$_->insert('end',"Test3");
}
$mw->Button(-text => "Werte ausgeben",
-command => sub {
foreach my$lb (@lb)
{
my @selected = $lb->curselection;
my $werte = "Werte: ";
$werte .= $lb->get($_) foreach @selected;
print "$werte\n";
}
})->pack(qw/-fill x -expand 1 -anchor n/);
MainLoop;
MfG PerlProfi