1

I'm writing a C/C++ application, this application is used directly by the user to give inputs, basically numerical values like a precise values, a range and something like that, think about an UI with some pieces like:

  • a numpad
  • a slider
  • an input field for numbers

and this is the C/C++ part, i expect to get just a bunch of values from this piece of code, the problem is that this values:

  • must be sended to Python in some way
  • can change in real time since my C/C++ is like an UI where things can change

i don't know of any design that can fit my request mainly because:

  • i know just the really basic stuff about Python, i can script something but i know nothing about Python internals
  • i have no idea how to make C++ and Python work together and how to do this in a signal/slot logic ( supposing that the signal/slot design is the right one for this app )
  • i have no idea how to provide my APIs to the users that would like to integrate my values in their own script for third part applications, imagine a random app that provides Python APIs too, i want to give to the user the option to code using both APIs in one script and maybe use this script in this third part application as any other set of APIs ( importing external APIs is possible when scripting in a third part application Python environment? )

That's how i would describe my problem and what i'm aiming to do, if something is not clear please comment.

recap: how to provide Python API from a C++ application using a signal/slot design in real time?

Thanks.

Ken
  • 2,105
  • 3
  • 19
  • 22
  • 1
    I would say the simplest interface would be to use sockets. But why would you write the UI part in C++? – TJD Sep 06 '12 at 14:33
  • @TJD because this UI is written in OpenGL basically, it's a solution related to what i want to achieve and it's one of the fixed point about this project; also the environments that i want to target do not offer Python support natively or do not offer Python support at all – Ken Sep 06 '12 at 14:36
  • The other main alternative to Boost Python would be SWIG. This related question has many answers discussing the options: http://stackoverflow.com/questions/456884/extending-python-to-swig-not-to-swig-or-cython – TJD Sep 06 '12 at 16:42

1 Answers1

4

Check out Boost.Python. It's a library which allows to use Python as a scripting language for a C++ program.

Philipp
  • 67,764
  • 9
  • 118
  • 153