Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 0e5088fcc44b42879b728a495456f4b6d4181de0 authored by cvs2svn on 17 October 1998, 19:44:20 UTC
This commit was manufactured by cvs2svn to create tag 'r152a2'.
Tip revision: 0e5088f
embed.html
<HTML>
<HEAD>
<TITLE>Embedding Python on the Mac</TITLE>
</HEAD>
<BODY>
<H1>Embedding Python on the Mac</H1>
<HR>
<B>Note</B>: if you have a binary-only release of MacPython you will not
have this demo installed. Go to
<a href="http://www.cwi.nl/~jack/macpython.html">Jack's MacPython Page</a>
to download either a source or a development release if you want to embed
Python in other applications. <p>

Embedding Python on the mac is pretty similar to embedding it on other
platforms, but a few points need mentioning:

<UL>
<LI> You call <CODE>PyMac_Initialize()</CODE> in stead of
<CODE>Py_Initialize()</CODE>. The prototype is in <CODE>macglue.h</CODE>.
This call initializes the toolbox, GUSI (if needed), sets up the correct
resource files and calls Py_Initialize.

<LI> You have to be consequent in your use of GUSI. If the library uses
it so should your program and vice versa.

<LI> The console-behaviour (close-on-exit, etc) is controlled by Python,
but you are of course free to change that after calling PyMac_Initialize().
</UL>

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 <code>EditPythonPrefs</code>. <p>

The most logical way to embed Python is to link it against the shared
library <code>PythonCore</code>. An example project and source can be
found in the <a href="embed">embed</a> folder. <p>

<b>Note</b>: you may think that you do not have the project file
<code>PythonCore</code> but actually you do: the standard installation
process deposits it in the <code>Extensions</code> folder in the system
folder under the name <code>PythonCore <i>version</i></code>. Add that file
to the project replacing <code>PythonCore</code>. <p>
</BODY>
</HTML>
back to top