NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on Sep 16, 2007 at 11:45 UTC
  • Comment on Reaped: perl tk select lines in listbox

Replies are listed 'Best First'.
Re: perl tk select lines in listbox
by zentara (Cardinal) on Aug 28, 2007 at 12:48 UTC
    #!/usr/bin/perl use warnings; use strict; use Tk; my $value; my $mw = MainWindow->new; my $entry = $mw->Entry( -state => 'readonly', -textvariable => \$value )->pack; my $lb = $mw->Listbox( -height => 0 )->pack; $lb->insert( 'end', qw/one two three four five six/ ); $lb->bind( '<ButtonPress-3>', [ \&setItem, \$value, Ev('@') ] ); sub setItem { my ( $lb, $valSR, $xy ) = @_; $lb->selectionClear( 0, 'end' ); my $index = $lb->index($xy); if ( defined($index) ) { $lb->selectionSet($index); $$valSR = $lb->get($index); } } MainLoop;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum