Embedding python GUI in an OpenGL app
Mike C. Fletcher
mcfletch at rogers.com
Tue May 27 11:28:54 EDT 2003
This approach is normally described as "extending" Python, rather than
"embedding" Python in an application (the distinction being which
application "drives" and which is "driven").
There shouldn't be any significant problems from the OpenGL side. Most
Python GUI libraries provide an OpenGL context, once you set that
context current from Python, you can simply call your C++ methods and
they will be directed to the current context.
If you need your application to be "in control" of the context (managing
size, creation, event handling etc.), you will likely need to muck
around in the internals of the particular GUI library to find the
function which returns a window handle for a given GUI window and pass
that to your C++ code constructor. You'll also need to provide all the
standard GUI-library mechanisms (set-current, passing in resize and
mouse events etc.) you can normally find out everything you need to do
for this simply by looking at the GUI library's OpenGL widget and
exposing the equivalent functionality during embedding.
Good luck,
Mike
Leigh McRae wrote:
>I want to use Python as the scripting language in my C++ application.
>There is a tonne of docs for that and I don't see any problems there.
>What I am wondering is about using a python GUI instead of writing my
>own. The application uses OpenGL directly without any framework libs
>such as SDL. Would it be possible to for a Python GUI to live with my
>app? The plan would be to use SWIG to make functions available for
>the GUI to use. Not so sure how sharing the same OpenGL window and
>context would work.
> Thank you in advance for any time spent.
>
>Leigh
>
>
--
_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
More information about the Python-list
mailing list