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

Reading Tk Window messages

by Stevo_ie (Initiate)
on Oct 08, 2002 at 13:44 UTC ( #203642=perlquestion: print w/replies, xml ) Need Help??
Stevo_ie has asked for the wisdom of the Perl Monks concerning the following question:

I need to read all the messages that are sent to a perl/tk window eg. mouse_moved, minimise_button_pressed, window_moved, window_resized.
Does anyone know how to retrieve these messages?
Thanx in advance,

Replies are listed 'Best First'.
Re: Reading Tk Window messages
by rir (Vicar) on Oct 08, 2002 at 18:18 UTC
    I suspect you need to hack Tk, use some debugging artifact
    or find another definition of your problem.

    Do to the diverse nature of Tk widgets, there is not
    going to be one SUPER class to alter.

    User level coding of Tk seems to only offer:

    $widget-bind( Tk::Button, "<Button-1>", sub{&handle_event});

    which will alter the specified binding for all
    instances of Tk::Button.

Re: Reading Tk Window messages
by PodMaster (Abbot) on Oct 09, 2002 at 12:28 UTC
    I suspect you're after Tk::bind and/or Tk::bindtags.

    see for tons of information

    update: see what rir said (hmm, i missed it?)

    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: Reading Tk Window messages
by ichimunki (Priest) on Oct 09, 2002 at 15:01 UTC
    Take a look at Tk::Toplevel, Tk::Wm, and Tk::after. You can set up a callback that runs periodically in your program to check for some of these things, using $toplevel->geometry() and $toplevel->status()-- this way you can detect when the geometry has changed, or if the user has minimzed or iconfied the application. You can't, unfortunately, directly catch these events as they happen. For that you might want to explore other GUI toolkits that explicitly offer these events as signals.

    One question that I would ask is: why? Tk should handle most of your redrawing needs, and I'm not sure it's interesting to know if the user has tried to minimize the window... unless you're trying to coerce certain behavior.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://203642]
Approved by diotalevi
Front-paged by tye
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2017-12-18 09:33 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (475 votes). Check out past polls.