1 <HTML><HEAD><TITLE>Macintosh Python crash course
</TITLE></HEAD>
3 <H1><IMG SRC=
"html.icons/python.gif">Macintosh Python crash course
</H1>
6 This set of documents provides an introduction to various aspects of
7 Python programming on the Mac. It is assumed that the reader is
8 already familiar with Python and, to some extent, with MacOS Toolbox
9 programming. Other readers may find something interesting here too,
10 your mileage may vary.
<p>
12 There is a companion document
<a href=
"using.html">Using Python on the Mac
</a>
13 which you should read before starting here: it explains the basics of using
14 python on the Macintosh.
<p>
16 Another set of Macintosh-savvy examples, more aimed at beginners, is
17 maintained by Joseph Strout, at
<A
18 HREF=
"http://www-acs.ucsd.edu/~jstrout/python/">
19 http://www-acs.ucsd.edu/~jstrout/python/
</A>.
22 The
<a href=
"http://www.python.org/doc/lib/Top.html">Python Library
23 Reference
</a> contains a section on
<a
24 href=
"http://www.python.org/doc/lib/Macintosh-Specific-Services.html">Macintosh-specific
25 modules
</a> that you should also read. Documentation is also available
26 in PostScript and other forms, see the
<a
27 href=
"http://www.python.org/doc/">documentation
</a> section on the
30 Some of these documents were actually written a long time ago and have seen
31 little maintainance, so use with care.
<p>
33 <H2>Table of contents
</H2>
37 <A HREF=
"example0.html">Using python to create Macintosh applications,
38 part zero
</A> whets your appetite by showing you how to ask the user
39 for a filename, and how to display a message. It explains about end-of-line
40 confusion while doing so.
43 <A HREF=
"example1.html">Using python to create Macintosh applications,
44 part one
</A> explains how to create a simple modal-dialog application
45 in Python. It also takes a glance at using the toolbox modules Res and
46 Dlg, and EasyDialogs for simple question-dialogs.
49 <A HREF=
"example2.html">Using python to create Macintosh applications,
50 part two
</A> turns the previous example program into a more complete
51 mac application, using a modeless dialog, menus, etc. It also explains
52 how to create applets, standalone applications written in Python.
55 <A HREF=
"freezing.html">Freezing Python programs
</A> extends on this concept,
56 and shows you how to create applications that can be used on machines without
57 a full Python installed. This one is probably best skipped on first contact
61 <A HREF=
"textedit.html">Using FrameWork and TextEdit
</A> shows you
62 how to use
<code>FrameWork
</code> application framework and the
63 <code>TextEdit
</code> toolbox to build a text editor.
66 <A HREF=
"waste.html">Using WASTE
</A> expands on this editor by using
67 WASTE, an extended TextEdit replacement.
70 <A HREF=
"plugins.html">Creating a C extension module on the Macintosh
</A>
71 is meant for the hardcore programmer, and shows how to create an
72 extension module in C. It also handles using Modulator to create the
73 boilerplate for your module, and creating dynamically-loadable modules
77 <A HREF=
"applescript.html">Using Open Scripting Architecture from Python
</A> explains
78 how to create a Python module interfacing to a scriptable application,
79 and how to use that module in your python program.
82 <A HREF=
"cgi.html">Using python to create CGI scripts
</A> is a preliminary
83 introduction to writing CGI scripts in Python and to writing scriptable applications
87 <A HREF=
"building.html">Building Mac Python from source
</A> explains
88 how to build a PPC or
68K interpreter from a source distribution.
91 <A HREF=
"embed.html">Embedding Python on the Mac
</A> is a minimal example of
92 how to embed Python in other Mac applications.
96 The Python distribution contains a few more examples, all unexplained:
99 <I>PICTbrowse
</I> is an application that locates PICT
100 resources and displays them, it demonstrates some quickdraw and the
101 resource and list managers. In the same folder you will find the very
102 similar scripts ICONbrowse and cicnbrowse.
105 <I>Imgbrowse
</I> displays image files in
106 many different formats (gif, tiff, pbm, etc). It shows how to use the
107 img modules on the mac.
110 <I>Quicktime
</I> has the standard
<code>MovieInWindow
</code> and
111 <code>VerySimplePlayer
</code> examples, re-coded in Python.
114 <I>Resources
</I>,
<I>Sound
</I> and
<I>Speech
</I> have some examples
115 on using the respective managers. In the
<i>Mac:Lib
</i> folder you
116 will also find modules that do useful things with the Communications
117 Toolbox, the Finder interface, etc.
120 <I>Printing
</I> has an example on using the Printing module to, you guessed
121 it, print from Python. The code is somewhat self-documenting. Donated
122 by Just van Rossum, who also donated the Printing module itself.
125 At some point in the (possibly distant) future, I will add chapters on
126 how to use bgen to create modules completely automatic and how to make
127 your Python program scriptable, but that will have to wait.
<p>
131 Please let me know if you miss critical information in this
132 document. I am quite sure that I will never find the time to turn it
133 into a complete MacPython programmers guide (which would probably be a
134 400-page book instead of
10 lousy html-files), but it should contain
135 at least the information that is neither in the standard Python
136 documentation nor in Inside Mac or other Mac programmers
140 <A HREF=
"http://www.cwi.nl/~jack">Jack Jansen
</A>,
141 <A HREF=
"mailto:jack@cwi.nl">jack@cwi.nl
</A>,
26-Jun-
98.