There is only one unusual thing about this Win32 app.
It cannot use the standard Windows GUI (e.g. HWNDS, window
controls, etc.) and it cannot use a console input/output.
The app would simply pass scripts to the Python interpreter
and the interpreter would run them.
Is this very hard? I read all the documentation and the FAQ,
but they never gets very far into the embedding topic.
Paul Pedriana
pped...@maxis.com
> I want to embed a Python interpreter into a Win32 program.
> Is this very hard? I read all the documentation and the FAQ,
> but they never gets very far into the embedding topic.
Check http://www.python.org/doc/ext/node19.html and Demo/embed/demo.c;
you don't really need to know more to just get the interpreter running
under your application... basically, you have to do something like:
#include "Python.h"
Py_Initialize();
PySys_SetArgv(argc, argv); // optional
...
PyRun_SimpleString(python code);
or PyRun_SimpleFile(fp, filename);
...
Py_Exit(); // optional
and link your application with the python14.dll
Cheers /F (http://hem1.passagen.se/eff)
No, it's easier than writing a C/C++ app from scratch for sure.
I suspect when you get going you'll want more interaction between
C and Python than you imagine right now, and there are some
tricks for win32. Look to
http://www.python.org/ftp/python/contrib/Web/
for grisha's nsapy_nt port of my nsapi embedding for a simple
but non-trivial example. Thanks again grisha!
Aaron Watters
=-=
Have you a brain?
I don't know, I've never looked.
From The Wizard of Oz (book)
I'm wondering, if there is an (easy) way to access or set C-variables
from python-code called in this way ?
Cheers
Dirk Engelmann