Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: how to use eventGenerate in Tk

by zentara (Archbishop)
on Oct 31, 2018 at 12:29 UTC ( #1224981=note: print w/replies, xml ) Need Help??


in reply to how to use eventGenerate in Tk

Hi, first off, you have a glaring error in your program flow. Once the line MainLoop is encountered, no further lines are processed until the MainLoop ( the Tk event loop system) is destroyed. So you never call eventGenerate until the Tk eventloop is gone, so it probably tries to run but throws an error.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = new MainWindow; my $label = $mw -> Label(-text=>"Hello World") -> pack(); my $button = $mw -> Button(-text => "Quit"); $button->bind('<ButtonPress-1>' => \&myexit); $button->pack; $button->eventGenerate('<ButtonPress-1>'); $mw->repeat(1000 => \&doit); sub doit { $button->focus; $button->eventGenerate('<ButtonPress-1>'); } MainLoop; sub myexit { print time."\n"; #exit; }

I'm not really a human, but I play one on earth. ..... an animated JAPH

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1224981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2019-10-15 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?