jfan8888 has asked for the wisdom of the Perl Monks concerning the following question:
I would like to programmatically trigger ButtonPress-1 event which is bind with a Listbox, but I can not get what I expected when eventGenerate is called. Below is my script:
use Tk; my $MW = MainWindow->new(); my $frame_lb = $MW->Frame(); $frame_lb->pack(-side => 'top', -pady => '20', -expand => 'n', -fill = +> 'both'); my $lbox = $frame_lb->Scrolled("Listbox", -scrollbars => "e", -selectmode => "single", -selectbackground => 'green', -height => 3)->pack(-side => 'left', -anchor => 'e'); my @list = ( "a", "b", "c", "d", "e", "f" ); $lbox->insert('end', @list ); $lbox->bind("<ButtonPress-1>" => sub { print "event trigged\n"; }); #trigger the event programmatically $lbox->eventGenerate("<ButtonPress-1>"); MainLoop;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: eventGenerate for Listbox
by kcott (Archbishop) on Dec 30, 2021 at 06:34 UTC | |
by jfan8888 (Initiate) on Dec 30, 2021 at 18:05 UTC | |
|
Re: eventGenerate for Listbox
by Anonymous Monk on Dec 30, 2021 at 04:23 UTC |