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 | |
Jack Jansen | 5f962c2 | 1996-04-10 14:52:59 +0000 | [diff] [blame] | 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> |
| 15 | |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 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>. |
| 20 | <P> |
| 21 | |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 22 | Some of these documents were actually written while I was working on a "real" |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 23 | project: creating a single-button application that will allow my |
| 24 | girlfriend to read her mail (which actually pass thry <EM>my</EM> |
| 25 | mailbox, so I get to read it too, but don't tell her:-) without her |
| 26 | having to worry about internet connections, unix commands, etc. The |
| 27 | application, when finished, will connect to the net using InterSLIP, |
| 28 | start a (pseudo-)POP server on unix using rsh and use AppleScript to |
| 29 | tell Eudora to connect to that server and retrieve messages. <p> |
| 30 | |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 31 | <BLOCKQUOTE> |
| 32 | If you want to try the examples with a version of Python earlier |
| 33 | than 1.3.1 you have to download some things. You need an updated |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 34 | version of <A HREF="update-to-1.3/FrameWork.py">FrameWork.py</A> (to |
| 35 | go in <CODE>Lib:mac</CODE> and updated <A |
| 36 | HREF="update-to-1.3/into-PlugIns.hqx">project templates</A> to go into |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 37 | the <CODE>PlugIns</CODE> folder for PPC users. <P> |
| 38 | The TextEdit and WASTE examples are not useable with distributions |
| 39 | before 1.3.3. |
| 40 | </BLOCKQUOTE> |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 41 | |
| 42 | If you are reading this document on the web and would prefer to read |
| 43 | it offline you can transfer the whole stuff (as a BinHexed StuffIt |
| 44 | archive) from <A HREF="complete.hqx"> here</A>. This archive includes |
| 45 | the fixes mentioned in the previous paragraph. <p> |
| 46 | |
| 47 | <H2>Table of contents</H2> |
| 48 | |
| 49 | <UL> |
| 50 | <LI> |
| 51 | <A HREF="example1.html">Using python to create Macintosh applications, |
| 52 | part one</A> explains how to create a simple modal-dialog application |
| 53 | in Python. It also takes a glance at using the toolbox modules Res and |
| 54 | Dlg, and EasyDialogs for simple question-dialogs. |
| 55 | |
| 56 | <LI> |
| 57 | <A HREF="example2.html">Using python to create Macintosh applications, |
| 58 | part two</A> turns the previous example program into a more complete |
| 59 | mac application, using a modeless dialog, menus, etc. It also explains |
| 60 | how to create applets, standalone applications written in Python. |
| 61 | |
| 62 | <LI> |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 63 | <A HREF="textedit.html">Using FrameWork and TextEdit</A> shows you |
| 64 | how to use <code>FrameWork</code> application framework and the |
| 65 | <code>TextEdit</code> toolbox to build a text editor. |
| 66 | |
| 67 | <LI> |
| 68 | <A HREF="waste.html">Using WASTE</A> expands on this editor by using |
| 69 | WASTE, an extended TextEdit replacement. |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 70 | |
| 71 | <LI> |
| 72 | <A HREF="plugins.html">Creating a C extension module on the Macintosh</A> |
| 73 | is meant for the hardcore programmer, and shows how to create an |
| 74 | extension module in C. It also handles using Modulator to create the |
| 75 | boilerplate for your module, and creating dynamically-loadable modules |
| 76 | on PowerPC Macs. |
| 77 | |
| 78 | <LI> |
| 79 | <A HREF="applescript.html">Using Open Scripting Architecture from Python</A> explains |
| 80 | how to create a Python module interfacing to a scriptable application, |
| 81 | and how to use that module in your python program. |
| 82 | </UL> |
| 83 | |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 84 | The Python distribution contains a few more examples, all unexplained: |
| 85 | <UL> |
| 86 | <LI> |
| 87 | <I>PICTbrowse</I> is an application that locates PICT |
| 88 | resources and displays them, it demonstrates some quickdraw and the |
| 89 | resource and list managers. |
| 90 | |
| 91 | <LI> |
| 92 | <I>Imgbrowse</I> displays image files in |
| 93 | many different formats (gif, tiff, pbm, etc). It shows how to use the |
| 94 | img modules on the mac. |
| 95 | |
| 96 | <LI> |
| 97 | <I>Quicktime</I> has the standard <code>MovieInWindow</code> and |
| 98 | <code>VerySimplePlayer</code> examples, re-coded in Python. |
| 99 | |
| 100 | <LI> |
| 101 | <I>Resources</I>, <I>Sound</I> and <I>Speech</I> have some examples |
| 102 | on using the respective managers. |
| 103 | </UL> |
| 104 | |
Jack Jansen | a630813 | 1996-03-18 13:38:52 +0000 | [diff] [blame] | 105 | At some point in the (possibly distant) future, I will add chapters on |
| 106 | how to use bgen to create modules completely automatic and how to make |
| 107 | your Python program scriptable, but that will have to wait. <p> |
| 108 | |
| 109 | <HR> |
| 110 | |
| 111 | Please let me know if you miss critical information in this |
| 112 | document. I am quite sure that I will never find the time to turn it |
| 113 | into a complete MacPython programmers guide (which would probably be a |
| 114 | 400-page book instead of 5 lousy html-files), but it should contain |
| 115 | at least the information that is neither in the standard Python |
| 116 | documentation nor in Inside Mac or other Mac programmers |
| 117 | documentation. <p> |
| 118 | |
| 119 | <HR> |
| 120 | <A HREF="http://www.cwi.nl/~jack">Jack Jansen</A>, |
Jack Jansen | 0836542 | 1996-04-19 15:56:08 +0000 | [diff] [blame^] | 121 | <A HREF="mailto:jack@cwi.nl">jack@cwi.nl</A>, 19-Apr-1996. |