in reply to selection problem with two Tk listboxes
Here is a really simple-minded extension of the code you posted, which should demonstrate what you're looking for:
#!/usr/bin/perl use strict; use Tk; my @list1 = qw/one two three four five six seven eight nine/; my @list2 = qw/green blue red yellow orange black brown white purple/; my $list_used; my $mw = MainWindow->new; my $lb1 = $mw->Scrolled('Listbox')->pack; my $lb2 = $mw->Scrolled('Listbox')->pack; my $b = $mw->Button(-text => "do it", -command => \&do_it)->pack; $lb1->insert( 'end', @list1 ); $lb2->insert( 'end', @list2 ); MainLoop; sub do_it { if ( $lb1->curselection ) { print " got item from lb1: ",$lb1->get($lb1->curselection),$/; } elsif ( $lb2->curselection ) { print " got item from lb2: ",$lb2->get($lb2->curselection),$/ +; } else { print "Nothing was selected\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: selection problem with two Tk listboxes
by fcvw (Novice) on May 03, 2005 at 06:25 UTC |