[Baypiggies] Qt with Python-based API strategy?
Shannon -jj Behrens
jjinux at gmail.com
Fri Mar 10 02:04:14 CET 2006
On 3/9/06, craig harris <craigwharris at comcast.net> wrote:
> I'm using Qt as a GUI for a C++ application and would like to use Python to
> support an API from inside the app. In this case I'll have to embed (call)
> python from Qt to invoke API commands, and then call the C++ engine from
> Python to execute most application functions. Is this scheme even
> possible,..or wise?
> I have read a bit about trying to do this and have gotten the impression
> that simultaneously calling python from Qt and vice-verse is very
> problematic. I have also heard about PyQt, and some recommend against this.
> Any suggestions for a strategy to use Python as an API inside a Qt/C++
> I was hoping to attend tonight's Bay Piggies meeting but have terrible cold.
As far as embedding Python into C++, I'm guessing that the Boost
library may be helpful. If you were going the other way, you would
use Swig, of course. Forgive me if I'm wrong--I'm just remembering a
former BayPiggies talk.
As far as mixing Python, C++, and QT, I think it's good practice with
most widget libraries to, in effect, have a single point of contact
between your code and the widget library. What I mean is that you
don't want multiple threads talking to the widget library at the same
time, of course. Just expand on that thinking. Just imagine that you
don't want QT to know what you're doing behind it's back, and perhaps
you'll be safe.
Of course, like I said, I haven't mixed C++, QT, and Python, although
I have written C++ apps using QT.
I assume your embedding in order to do scripting of your application.
That makes sense. When this isn't the case, I've occassionally split
the C++ and Python into separate processes and used a thin RPC
mechanism between them. That doesn't sound like what you want though.
More information about the Baypiggies