Search code examples
c++pythoncapisignals-slots

Application design for exchanging values between C/C++ and Python


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.


Solution

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