blob: e5ac7a0eb9c146f0e47c9537adcfcb710ee59365 [file] [log] [blame]
Jack Jansen6ad8d131997-01-15 16:53:37 +00001<HTML>
2<HEAD>
3<TITLE>Embedding Python on the Mac</TITLE>
4</HEAD>
5<BODY>
6<H1>Embedding Python on the Mac</H1>
7<HR>
Jack Jansenae4300f1998-01-06 16:50:44 +00008<B>Note</B>: if you have a binary-only release of MacPython you will not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +00009have this demo installed. Install the developer option (in the standard installer) or go to
Jack Jansenae4300f1998-01-06 16:50:44 +000010<a href="http://www.cwi.nl/~jack/macpython.html">Jack's MacPython Page</a>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000011to download either a source release if you want to embed
Jack Jansenae4300f1998-01-06 16:50:44 +000012Python in other applications. <p>
Jack Jansen6ad8d131997-01-15 16:53:37 +000013
14Embedding Python on the mac is pretty similar to embedding it on other
15platforms, but a few points need mentioning:
16
17<UL>
18<LI> You call <CODE>PyMac_Initialize()</CODE> in stead of
19<CODE>Py_Initialize()</CODE>. The prototype is in <CODE>macglue.h</CODE>.
20This call initializes the toolbox, GUSI (if needed), sets up the correct
21resource files and calls Py_Initialize.
22
23<LI> You have to be consequent in your use of GUSI. If the library uses
24it so should your program and vice versa.
25
26<LI> The console-behaviour (close-on-exit, etc) is controlled by Python,
27but you are of course free to change that after calling PyMac_Initialize().
28</UL>
29
30The Python environment is started with a dummy argc and argv, and initial
31startup options are obtained through the usual means, except that the
32user pression the option-key will not result in an interactive dialog.
33You can, however, set startup options on your program in the same way as you
34do for applets, by dragging your application to <code>EditPythonPrefs</code>. <p>
35
Jack Jansen3412c5d1997-08-27 14:08:22 +000036The most logical way to embed Python is to link it against the shared
37library <code>PythonCore</code>. An example project and source can be
Jack Jansena2139fe1998-02-25 15:40:35 +000038found in the <a href="embed">embed</a> folder. <p>
Jack Jansen6ad8d131997-01-15 16:53:37 +000039
Jack Jansena2139fe1998-02-25 15:40:35 +000040<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
42process deposits it in the <code>Extensions</code> folder in the system
43folder under the name <code>PythonCore <i>version</i></code>. Add that file
44to the project replacing <code>PythonCore</code>. <p>
Jack Jansen6ad8d131997-01-15 16:53:37 +000045</BODY>
46</HTML>