append(): Fixing the test for convertability after consultation with
[python/dscho.git] / Mac / Demo / embed.html
blobe0ca756498bf7e3ef7e8be54b19317efd7e46936
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>
8 <B>Note</B>: if you have a binary-only release of MacPython you will not
9 have this demo installed. Install the developer option (in the standard installer) or
10 a source release if you want to embed
11 Python in other applications. <p>
13 Embedding Python on the mac is pretty similar to embedding it on other
14 platforms, but a few points need mentioning:
16 <UL>
17 <LI> You call <CODE>PyMac_Initialize()</CODE> in stead of
18 <CODE>Py_Initialize()</CODE>. The prototype is in <CODE>macglue.h</CODE>.
19 This call initializes the toolbox, GUSI (if needed), sets up the correct
20 resource files and calls Py_Initialize.
22 <LI> You have to be consequent in your use of GUSI. If the library uses
23 it so should your program and vice versa.
25 <LI> The console-behaviour (close-on-exit, etc) is controlled by Python
26 but you can overwrite this with <code>PyMac_SetConsoleHandler()</code>.
27 </UL>
29 The Python environment is started with a dummy argc and argv, and initial
30 startup options are obtained through the usual means, except that the
31 user pression the option-key will not result in an interactive dialog.
32 You can, however, set startup options on your program in the same way as you
33 do for applets, by dragging your application to <code>EditPythonPrefs</code>. <p>
35 The most logical way to embed Python is to link it against the shared
36 library <code>PythonCore</code>. An example project and source can be
37 found in the <a href="embed">embed</a> folder. <p>
39 This example code also shows how to override the console: if you pass the
40 <code>-q</code> argument in the argument box output is thrown away. If you
41 pass the <code>-d</code> option the output is sent to <code>DebugStr</code>
42 (so be sure to use this only when running the example under a debugger).
43 </BODY>
44 </HTML>