Embedding Python on the Mac
Embedding Python on the mac is pretty similar to embedding it on other
platforms, but a few points need mentioning:
- You call
PyMac_Initialize()
in stead of
Py_Initialize()
. The prototype is in macglue.h
.
This call initializes the toolbox, GUSI (if needed), sets up the correct
resource files and calls Py_Initialize.
- You have to be consequent in your use of GUSI. If the library uses
it so should your program and vice versa.
- The console-behaviour (close-on-exit, etc) is controlled by Python,
but you are of course free to change that after calling PyMac_Initialize().
The Python environment is started with a dummy argc and argv, and initial
startup options are obtained through the usual means, except that the
user pression the option-key will not result in an interactive dialog.
You can, however, set startup options on your program in the same way as you
do for applets, by dragging your application to EditPythonPrefs
.
The most logical way to embed Python is to link it against the shared library
PythonCorePPC
or PythonCoreCFM68K
. An example project
and source can be found in the embed folder.