momo33 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new; my $gui_period = $mw->Scrolled( qw/Listbox -height 5 -width 20 -background white -selectforeground red/ ); my $gui_report = $mw->Scrolled( qw/Listbox -height 5 -width 20 -background white -selectforeground blue/ ); $gui_period->grid( -row => 0, -column => 0, -rowspan => 1, -sticky => +'nsew' ); $gui_report->grid( -row => 1, -column => 0, -rowspan => 1, -sticky => +'nsew' ); $gui_period->bind( '<ButtonRelease-1>' => \&show_period ); $gui_report->bind( '<ButtonRelease-1>' => \&show_report ); my ($item); my @periodlist = qw/one two three four/; foreach $item (@periodlist) { $gui_period->insert( 'end', $item ); } my @reportlist = qw/first second third fourth/; foreach $item (@reportlist) { $gui_report->insert( 'end', $item ); } MainLoop; sub show_period { my @index = $gui_period->curselection(); my $index = $index[0]; $gui_period->selectionSet($index); print "period: $index $periodlist[$index]\n"; } sub show_report { my @index = $gui_report->curselection(); my $index = $index[0]; $gui_report->selectionSet($index); print "report: $index $reportlist[$index]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: simultaneous selections in Tk
by zentara (Cardinal) on Nov 02, 2008 at 16:40 UTC | |
by momo33 (Beadle) on Nov 02, 2008 at 18:33 UTC | |
by zentara (Cardinal) on Nov 02, 2008 at 18:49 UTC | |
by graff (Chancellor) on Nov 02, 2008 at 19:14 UTC | |
by zentara (Cardinal) on Nov 02, 2008 at 19:44 UTC |