Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: how to use eventGenerate in Tk

by zentara (Archbishop)
on Oct 31, 2018 at 12:29 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1224981]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2024-04-23 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found