
Greg suggest a direct call from C/C++ to queue an event. Tom Greg Couch wrote:
Tom,
You need to link with tcl (actually tcl stubs) and use the Tcl_ThreadQueueEvent function.
- Greg
On Tue, 8 Apr 2008, Tom Goddard wrote:
From: Tom Goddard <goddard@cgl.ucsf.edu> Sender: chimera-dev-bounces@cgl.ucsf.edu To: Gergely Nagy <gergelynagy76@gmail.com> Cc: chimera-dev@cgl.ucsf.edu Date: Tue, 08 Apr 2008 12:39:58 -0700 Subject: Re: [chimera-dev] Multi-touch and Chimera Received-SPF: pass (cgl.ucsf.edu: 169.230.27.3 is authenticated by a trusted mechanism) Received-SPF: pass (cgl.ucsf.edu: 169.230.27.3 is authenticated by a trusted mechanism)
Hi Greg,
Chimera is written in Python and C++. The C++ is used for OpenGL rendering and for optimizing calculations. The event loop and user interface is all in Python. The touch events and the actions they trigger should definitely be in Python. It looks very reasonable to use Boost Python to wrap the C++ touchlib library or parts of it to make it accessible to Python.
http://wiki.python.org/moin/boost.python/GettingStarted
http://www.boost.org/doc/libs/1_35_0/libs/python/doc/index.html
We use an in-house wrapping program (WrapPy). Wrapping C/C++ for Python is often done with package called SWIG.
We use the Tcl/Tk event loop using the Python/Tk interface module called Tkinter. You can put custom Tk event types such as touch events in the event queue but I haven't figured out a way to do it. The trouble is that you typically will get an event from a callback in C/C++ code. I recently tried passing such an event (for a Space Navigator 6-dof input device) to a Python routine. It resulted in crashes because Tkinter is designed so that only it can call Python code. It has some complicated thread locking code that releases a Python lock and my event handler called into Python without having that Python lock, tried to do some Tk call and crashed. Probably the Python lock can be acquired in the C/C++ callback, but then if that Python code does Tk calls to add an event there may be additional problems with Tkinter's Tk lock which is inaccessible. So some work is needed to figure out how to get the C/C++ callback events into the Tk event loop. Once that is solved everything can be done in Python with event handlers processing those Tk events to cause any desired Chimera actions.
Tom