#!/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( '' => \&show_period ); $gui_report->bind( '' => \&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"; }