title: Embedding a python interpreter to c++
body: <p>You'll have to forgive me if this question has been answered, but I haven't been able to find anything that specifically talks about what I need.</p>
  
  <p>I am attempting to embed a python interpreter into a GUI written in C++.  To describe it a bit more fully, I have a series of images that will be displayed in a window.  These images will be streamed from a server, along with various information about the images and how they compare to each other.  The GUI will also have a large text area at the bottom with a prompt (like the '>>>' prompt in the python CLI) that the user can type valid python code into, then the app executes that code based on the information it has on the image currently being displayed.</p>
  
  <p>For example, if the image is stored in a struct that contains height and width information (<code>image-&gt;height</code> and <code>image-&gt;width</code>), and I have written in Python a class that interfaces with the data currently displayed (everything would do what it looks like it should do), I need to be able to execute the following and get the output:</p>
  
  <pre><code>&gt;&gt;&gt; from image import image #custom module and class for interfacing with my GUI
  &gt;&gt;&gt; img = image.get_current_image() #returns a Python object relating to the image currently displayed
  &gt;&gt;&gt; img.width
  800
  &gt;&gt;&gt;img.height
  600
  &gt;&gt;&gt; img.aspect_ratio()
  4:3
  </code></pre>
  
  <p>I am aware of a few methods of accessing c++ classes from python code, such as <a href="http://www.boost.org/doc/libs/1_50_0/libs/python/doc/" rel="noreferrer">Boost Python</a>.  What I am not sure how to do is a create the interpreter inside a C++ GUI.  The issue is the python and C++ must communicate with each other in realtime, and must share memory.  For example, the python module may contain a <code>to_grayscale()</code> function that converts the image to grayscale, which would require that the python module retireve the image from C++, convert it, and send it back to be rerendered.</p>
  
  <p>Just to make it clear, I don't need help doing that conversion or anything like that.  Just how do I integrate the interpreter with C++?</p>
  
  <p>Thanks!</p>