Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (1)
As of 2022-10-02 06:02 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (7 votes). Check out past polls.