TK custom events.

P

PWR

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.
 
H

Hidetoshi NAGAI

From: "PWR" <[email protected]>
Subject: TK custom events.
Date: Thu, 12 Jan 2006 22:13:18 +0900
Message-ID: said:
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.
 
P

PWR

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.
 
R

ruby talk

------=_Part_17523_18034113.1137083984449
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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.

------=_Part_17523_18034113.1137083984449--
 
H

Hidetoshi NAGAI

From: "PWR" <[email protected]>
Subject: Re: TK custom events.
Date: Thu, 12 Jan 2006 23:43:05 +0900
Message-ID: said:
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. :)
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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top