Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 1 | <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 Jansen | ae4300f | 1998-01-06 16:50:44 +0000 | [diff] [blame^] | 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> |
Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 13 | |
| 14 | Embedding Python on the mac is pretty similar to embedding it on other |
| 15 | platforms, 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>. |
| 20 | This call initializes the toolbox, GUSI (if needed), sets up the correct |
| 21 | resource files and calls Py_Initialize. |
| 22 | |
| 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. |
| 25 | |
| 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(). |
| 28 | </UL> |
| 29 | |
| 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> |
| 35 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 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. |
Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 39 | |
| 40 | </BODY> |
| 41 | </HTML> |