Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ListBox

1 view
Skip to first unread message

terminalsplash

unread,
Nov 2, 2001, 7:18:32 PM11/2/01
to
Hi

I want to select (higlight, activate) listbox entry when I click a
button.
$val_list =
$win->Listbox("width"=>25,"height"=>4,-foreground=>"blue",-background=>"whit
e",-exportselection=>0,-selectbackground=>"cyan")->pack(side=>"left");
$val_list->insert("end",@valfiles);
$val_list->bind("<Double-1>",\&get_val);
Can some one tell me how to enable an enry in the listbox.

Thanks in advance

Martin Raspe

unread,
Nov 5, 2001, 3:42:24 AM11/5/01
to
terminalsplash schrieb:

> I want to select (higlight, activate) listbox entry when I click a button.

> Can some one tell me how to enable an enry in the listbox.

There's a difference between "activate" and "select" (see below).

Martin

#------------------------------------------------------------
use Tk;

my $count;
my $win = MainWindow->new();
$val_list = $win->Listbox(
-width => 25,
-height => 4,
-foreground => "blue",
-background=>"white",
-exportselection => 0,
-selectbackground => "cyan",
)->pack(
side => "left",
);
$win->Button(
-text => 'Print values',
-command => \&get_val,
)->pack(
side => 'bottom',
fill => 'x',
);
$win->Button(
-text => 'Select next entry',
-command => sub {$val_list->selectionSet($count++) },
)->pack(
side => 'bottom',
fill => 'x',
);
$win->Button(
-text => 'Activate next entry',
-command => sub { $val_list->activate($count++) },
)->pack(
side => 'bottom',
fill => 'x',
);
$val_list->focus;
@valfiles = (<*>);


$val_list->insert("end",@valfiles);
$val_list->bind("<Double-1>",\&get_val);

MainLoop;

sub get_val {
print "Active: ", $val_list->get(active), "\nSelected: ";
print $val_list->get($_), " " for $val_list->curselection;
print "\n";
};

0 new messages