TK custom events

Hi, does anyone know how to set up a custom event which the Tk main
loop will pick up i.e. I want to be able to create an event/handler
which allows me to dispatch my own events to the Tk main loop. Any help
gratfully received.

Peter.

From: “PWR” [email protected]
Subject: TK custom events.
Date: Thu, 12 Jan 2006 22:13:18 +0900
Message-ID: [email protected]

Hi, does anyone know how to set up a custom event which the Tk main
loop will pick up i.e. I want to be able to create an event/handler
which allows me to dispatch my own events to the Tk main loop. Any help
gratfully received.

To answer your question, more details of your own events are required.
Please explain what kind of events you want to treat.

What if i wanted to get the location of a file that i click and drag
over
lets say a TkButton?

Becker

I’m wanting to do the following,
(1) Monitor an incoming socket with another thread and queue received
messages.
(2) Supply an event to the Tk mainloop when data arrives which causes
it to call a handler which reads the queued data.

The idea is to avoid a solution which involves directly calling Tk
methods from the other thread in case there are any thread safety
issues. I may be being over cautious.

Peter.

Problem solved, in fact it never existed! Thanks a lot.

Peter.

From: “PWR” [email protected]
Subject: Re: TK custom events.
Date: Thu, 12 Jan 2006 23:43:05 +0900
Message-ID: [email protected]

The idea is to avoid a solution which involves directly calling Tk
methods from the other thread in case there are any thread safety
issues. I may be being over cautious.

Don’t worry about that. :slight_smile:
All Tk calls out of the ‘Tk.mainloop’ thread are automatically
serialized on the event queue and done in the ‘Tk.mainloop’.
That is not a work of a user, but a work of ‘tcltklib’.

Even though so, if you want to use your own event,
please try TkVirtualEvent and Tk.event_generate.
If those cannot satisfy you, you may have to write C functions.
If so, please read how to treat TclTkIp#invoke method on ‘tcltklib.c’.