Thread von mehreren listboxen selectieren (6 answers)
Opened by fraggs at 2006-12-01 11:20

PerlProfi
 2006-12-01 19:45
#46003 #46003
User since
2006-11-29
340 Artikel
BenutzerIn
[default_avatar]
Damit man in mehreren Listboxen selektieren kann, muss man die Option -exportselection auf 0 setzen.

Beispiel:
Code: (dl )
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

View full thread von mehreren listboxen selectieren