Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame^] | 1 | <HTML><HEAD><TITLE>Macintosh Python crash course</TITLE></HEAD> |
| 2 | <BODY> |
| 3 | <H1><IMG SRC="html.icons/python.gif">Macintosh Python crash course</H1> |
| 4 | <HR> |
| 5 | |
| 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> |
| 11 | |
| 12 | Another set of Macintosh-savvy examples, more aimed at beginners, is |
| 13 | maintained by Joseph Strout, at <A |
| 14 | HREF="http://www-acs.ucsd.edu/~jstrout/python/"> |
| 15 | http://www-acs.ucsd.edu/~jstrout/python/</A>. |
| 16 | <P> |
| 17 | |
| 18 | The document was actually written while I was working on a "real" |
| 19 | project: creating a single-button application that will allow my |
| 20 | girlfriend to read her mail (which actually pass thry <EM>my</EM> |
| 21 | mailbox, so I get to read it too, but don't tell her:-) without her |
| 22 | having to worry about internet connections, unix commands, etc. The |
| 23 | application, when finished, will connect to the net using InterSLIP, |
| 24 | start a (pseudo-)POP server on unix using rsh and use AppleScript to |
| 25 | tell Eudora to connect to that server and retrieve messages. <p> |
| 26 | |
| 27 | <CITE> |
| 28 | If you want to try the examples here you will have to download some |
| 29 | fixes to the 1.3 distribution to your Macintosh. You need an updated |
| 30 | version of <A HREF="update-to-1.3/FrameWork.py">FrameWork.py</A> (to |
| 31 | go in <CODE>Lib:mac</CODE> and updated <A |
| 32 | HREF="update-to-1.3/into-PlugIns.hqx">project templates</A> to go into |
| 33 | the <CODE>PlugIns</CODE> folder for PPC users. |
| 34 | Users of 1.3.1 or later distributions don't need these fixes.<P> |
| 35 | </CITE> |
| 36 | |
| 37 | If you are reading this document on the web and would prefer to read |
| 38 | it offline you can transfer the whole stuff (as a BinHexed StuffIt |
| 39 | archive) from <A HREF="complete.hqx"> here</A>. This archive includes |
| 40 | the fixes mentioned in the previous paragraph. <p> |
| 41 | |
| 42 | <H2>Table of contents</H2> |
| 43 | |
| 44 | <UL> |
| 45 | <LI> |
| 46 | <A HREF="example1.html">Using python to create Macintosh applications, |
| 47 | part one</A> explains how to create a simple modal-dialog application |
| 48 | in Python. It also takes a glance at using the toolbox modules Res and |
| 49 | Dlg, and EasyDialogs for simple question-dialogs. |
| 50 | |
| 51 | <LI> |
| 52 | <A HREF="example2.html">Using python to create Macintosh applications, |
| 53 | part two</A> turns the previous example program into a more complete |
| 54 | mac application, using a modeless dialog, menus, etc. It also explains |
| 55 | how to create applets, standalone applications written in Python. |
| 56 | |
| 57 | <LI> |
| 58 | In the Python distribution two more examples are included without |
| 59 | explanation. <I>PICTbrowse</I> is an application that locates PICT |
| 60 | resources and displays them, it demonstrates some quickdraw and the |
| 61 | resource and list namagers. <I>Imgbrowse</I> displays image files in |
| 62 | many different formats (gif, tiff, pbm, etc). It shows how to use the |
| 63 | img modules on the mac. |
| 64 | |
| 65 | <LI> |
| 66 | <A HREF="plugins.html">Creating a C extension module on the Macintosh</A> |
| 67 | is meant for the hardcore programmer, and shows how to create an |
| 68 | extension module in C. It also handles using Modulator to create the |
| 69 | boilerplate for your module, and creating dynamically-loadable modules |
| 70 | on PowerPC Macs. |
| 71 | |
| 72 | <LI> |
| 73 | <A HREF="applescript.html">Using Open Scripting Architecture from Python</A> explains |
| 74 | how to create a Python module interfacing to a scriptable application, |
| 75 | and how to use that module in your python program. |
| 76 | </UL> |
| 77 | |
| 78 | At some point in the (possibly distant) future, I will add chapters on |
| 79 | how to use bgen to create modules completely automatic and how to make |
| 80 | your Python program scriptable, but that will have to wait. <p> |
| 81 | |
| 82 | <HR> |
| 83 | |
| 84 | Please let me know if you miss critical information in this |
| 85 | document. I am quite sure that I will never find the time to turn it |
| 86 | into a complete MacPython programmers guide (which would probably be a |
| 87 | 400-page book instead of 5 lousy html-files), but it should contain |
| 88 | at least the information that is neither in the standard Python |
| 89 | documentation nor in Inside Mac or other Mac programmers |
| 90 | documentation. <p> |
| 91 | |
| 92 | <HR> |
| 93 | <A HREF="http://www.cwi.nl/~jack">Jack Jansen</A>, |
| 94 | <A HREF="mailto:jack@cwi.nl">jack@cwi.nl</A>, 6-Mar-1996. |