[Pythonmac-SIG] Invisible Embedding?
Jon Bradley
jbradley@whiplashmedia.com
Thu, 04 Oct 2001 07:33:13 -0400
Hey everyone,
In a current project I'm working on, we're embedding Python into a 3d
application. Things seem to be going right along, but I ran into an issue
that I have no idea about, nor experience. I thought I would pass the
question on to all you knowledgeable folks out there to see if you might
know of any resources or examples I might be able to get a hold of.
Embedding Python is cool and all - but what if I wanted to embed Python in
an invisible manner? Meaning, in this 3D application, a user creates an
extension that's compiled, somehow. That extension is written in Python, or
C or C++ but is recognized by the application as just another extension. I
want to find a mechanism whereby Python code in that extension is sent to
the 'invisible' Python interpreter (if Python code is found to be used in
that extension) and whatever is needed to be done is executed or arguments
are returned in the manner they need to be.
Example :
1. Python is embedded in the application (invisibly?)
2. User uses an SDK (which would probably be Python) to compile an extension
that's written in Python (or uses Python to write the extension).
3. The extension shows up in an extension palette and the user can click on
it and execute away.
4. Say this extension ... oh, modifies some selected geometry in a current
context.
5. How the heck can it be done without an interpreter ever being visible or
opened??!?
The reasons for doing this are all over the place. For one, we want to have
Python embedded so that the user can interface with the interpreter and do
whatever needs to be done. BUT, I'd also like them to be able to compile
modules (I'll just call them extensions) that the application, or Python
will recognize that don't require a interpreter session to be visible to the
user - a behind-the-scenes approach.
The good thing about being able to do this is that we'd be able to have
Python in the application running tools, extensions, animation things, etc.
without the user ever having to touch code or type anything (I would love to
enable this brainless approach). Just click and go. Also, it would be much
easier to expand and work with as the application grows.
'Power users' would have the ability to actually get down to the core of any
found 'extension' and import them into the interpreter and execute specific
functional elements in that extension (module of course). This method would
be very very useful for all sorts of good reasons.
Now ... question is ... can it be done, and does anyone have a clue how?
Thanks everyone!!
Jon