COM, Tk and threads

Jon Bills jon_bills at hotmail.com
Thu May 2 06:27:39 EDT 2002


Hello list,

I am currently working on a Python project which requires the use of COM
to integrate with existing Windows applications, and I've run into
trouble running a GUI at the same time. I'll attempt to explain.
Firstly, I have a COM server written in C++, which I can't change. One
of the interface methods takes a pointer to an IDispatch, and registers
that interface as a callback to receive various messages. I'd like those
messages to be displayed in a GUI window, and I'd like to write the GUI
in Python.

So, I've written a Python COM server which registers its dispinterface
with the C++ server, and that all works fine. It also spawns a Tk GUI in
a seperate thread, and the two threads communicate via a mutex-protected
queue. I also have a client script which starts up the Python COM
server, registers it with the C++ server and then tells the server to
start the GUI thread. The problem is that I want that client script to
wait for the GUI thread to terminate before making further calls to
unregister the python COM server and before ending the script. Whenever
I run the script, naturally it drops off the end and everything
terminates. I need to be able to wait on the GUI thread, but the only
method I've found so far results in tying up the main thread, thus
preventing the COM server from receiving its callbacks. Is there a way
that I can signal an event from the Python COM server to the Python
script that the GUI thread has terminated, so that the script may wait
on that event?


-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



More information about the Python-list mailing list