Hi, I recently ported a linux/mac wxpython program over to visual studio. Unlike linux/mac I can’t depend on a user having a shell prompt available to invoke the python interpreter, so I created a simple executable for each script that uses the python embedding routines to start the interpreter. In visual studio these appear as another executable project, the user can select one for debugging, execution, or whatever.
// Setup python.
Py_Initialize();
PySys_SetArgv(argc,argv);
// Add hard coded paths.
PyRun_SimpleString(“import sys\n”);
// These lines added by CMAKE PyRun_SimpleString(“sys.path.append(r’/pathtobuilds/python’)\n”); PyRun_SimpleString(“sys.path.append(r’/pathtobuilds/lib’)\n”);
// Invoke the script.
PyRun_SimpleString( &buffer[0] );
These little programs work great in linux too since the user can run a single binary to start up the application instead of having to set the python path first. The problem is on Mac: starting the script up this way causes the familiar error:
This program needs access to the screen.
Please run with ‘pythonw’, not ‘python’, and only when you are logged
in on the main display of your Mac.
I’m not sure how to embed “pythonw” instead of the usual python libraries. From what I can tell “pythonw” is linked to the same libraries as “python”, so there must be an API difference. Does anyone have an idea? I am using 2.4.8 and the default leopard libraries.
-Thanks