3 <TITLE>Embedding Python on the Mac
</TITLE>
6 <H1>Embedding Python on the Mac
</H1>
8 <B>Note
</B>: if you have a binary-only release of MacPython you will not
9 have this demo installed. Go to
10 <a href=
"http://www.cwi.nl/~jack/macpython.html">Jack's MacPython Page
</a>
11 to download either a source or a development release if you want to embed
12 Python in other applications.
<p>
14 Embedding Python on the mac is pretty similar to embedding it on other
15 platforms, but a few points need mentioning:
18 <LI> You call
<CODE>PyMac_Initialize()
</CODE> in stead of
19 <CODE>Py_Initialize()
</CODE>. The prototype is in
<CODE>macglue.h
</CODE>.
20 This call initializes the toolbox, GUSI (if needed), sets up the correct
21 resource files and calls Py_Initialize.
23 <LI> You have to be consequent in your use of GUSI. If the library uses
24 it so should your program and vice versa.
26 <LI> The console-behaviour (close-on-exit, etc) is controlled by Python,
27 but you are of course free to change that after calling PyMac_Initialize().
30 The Python environment is started with a dummy argc and argv, and initial
31 startup options are obtained through the usual means, except that the
32 user pression the option-key will not result in an interactive dialog.
33 You can, however, set startup options on your program in the same way as you
34 do for applets, by dragging your application to
<code>EditPythonPrefs
</code>.
<p>
36 The most logical way to embed Python is to link it against the shared
37 library
<code>PythonCore
</code>. An example project and source can be
38 found in the
<a href=
"embed">embed
</a> folder.
<p>
40 <b>Note
</b>: you may think that you do not have the project file
41 <code>PythonCore
</code> but actually you do: the standard installation
42 process deposits it in the
<code>Extensions
</code> folder in the system
43 folder under the name
<code>PythonCore
<i>version
</i></code>. Add that file
44 to the project replacing
<code>PythonCore
</code>.
<p>