Embedding Python on the mac is pretty similar to embedding it on other platforms, but a few points need mentioning:
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.
PyMac_SetConsoleHandler()
.
EditPythonPrefs
.
The most logical way to embed Python is to link it against the shared
library PythonCore
. An example project and source can be
found in the embed folder.
This example code also shows how to override the console: if you pass the
-q
argument in the argument box output is thrown away. If you
pass the -d
option the output is sent to DebugStr
(so be sure to use this only when running the example under a debugger).