[Edu-sig] re: Pygeo, platforms, wx and Tk

Tim Freeman tim at fungible.com
Wed Dec 15 16:15:47 CET 2004


From: Arthur <ajsiegel at optonline.net>
>So I have 2 windows - one is a Display for the VPython rendering and is
>actually constructed as a class derived from the VPython display object
>(native on Windows, GTK1 on linux) The other is a TK control panel.

Hi.  I'm new here.  Now we have two Tim's.

I've run into the duelling event loop scenario before, but not with
these specific toolkits.  The solution then was to refactor a bit and
arrange to have one event loop, rather than having multiple threads.
To implement a similar solution in this case, you would have to find
the entry point that processes one GTK event, and another entrypoint
that processes one TK event, then you do something like this:

while True:
   get an event
   if the event came from the TK window:
      process it as a TK event
   else:
      process it as a GTK event

Unfortunately, I suspect you'll lose OS portability when you do that,
since the base events are different sorts of things for MSWindows and
X Windows.

The bad solution I encountered before had two threads with independent
event loops.  The symptom then was that events would occasionally get
ignored when the event loop in wrong thread picked them up and didn't
know what to do with them.

Another solution would be to have two completely separate processes,
each with its own connection to the window system.  This way each
event loop is guaranteed to get the events from the right window.
Whether this is possible for you depends on whether it's feasible for
your GTK and your TK code to interact the way you want when they are
in separate processes.

-- 
Tim Freeman               http://www.fungible.com           tim at fungible.com
Programmer/consultant in the Sunnyvale, CA area.    I'm presently available.


More information about the Edu-sig mailing list