Look at this, and "perldoc Tk::MListbox" for getRow.
#!/usr/bin/perl
use Tk;
use Tk::MListbox;
use strict;
use warnings;
my $mw = new MainWindow();
$mw->fontCreate('big', -family=>'arial',
-weight=>'bold', -size=> 18 );
$mw->fontCreate('medium', -family=>'arial',
-weight=>'bold', -size=> 14 );
my $frame = $mw->Frame(-bd => 2, -relief => 'raised')->pack(-expand =>
+ 1, -fill => 'both');
my $scrolledMListbox = $frame->Scrolled(
qw/MListbox -selectmode browse -scrollbars oe -font medium /
)->pack(-expand => 1, -fill => 'both');
$scrolledMListbox->columnInsert('end', -text => "Sort Me",-font => 'b
+ig');
for(1..20){
$scrolledMListbox->insert('end', [int rand 20] );
}
$scrolledMListbox->bindRows('<ButtonRelease-1>',
sub {
my ($w, $infoHR) = @_;
print "@_\n";
print "You selected row: " . $infoHR->{-row} .
" in column: " . $infoHR->{-column} . "\n";
print $scrolledMListbox->getRow( $scrolledMListbox->curselection()
+->[0] ),"\n";
}
);
MainLoop;
|