Mercurial > cpython-lru_cache-weakref
annotate Doc/mac/using.tex @ 32527:0da660e05e69 legacy-trunk
"#if WITH_THREAD" is incorrect; must be #ifdef instead; WITH_THREAD
isn't always set to an integer value when it's defined.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Wed, 07 Jul 2004 20:42:07 +0000 |
| parents | b2a0cd2e9d55 |
| children | abe04e77a4b0 |
| rev | line source |
|---|---|
|
27833
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
1 \chapter{Using Python on a Mac OS 9 Macintosh \label{using}} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
2 \sectionauthor{Bob Savage}{bobsavage@mac.com} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
3 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
4 Using Python on a Macintosh, especially on Mac OS 9 (MacPython-OSX |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
5 includes a complete \UNIX{} Python) can seem like something completely |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 different than using it on a \UNIX-like or Windows system. Most of the |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
7 Python documentation, both the ``official'' documentation and published |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
8 books, describe only how Python is used on these systems, causing |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
9 confusion for the new user of MacPython-OS9. This chapter gives a brief |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
10 introduction to the specifics of using Python on a Macintosh. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
11 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 |
|
27833
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
13 The section on the IDE (see Section \ref{IDE}) is relevant to MacPython-OSX |
|
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
14 too. |
|
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
15 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
16 \section{Getting and Installing MacPython-OSX \label{getting-OSX}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
17 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
18 As of Python 2.3a2 the only sure way of getting MacPython-OSX on your machine |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
19 is getting a source distribution and building what is called a "framework Python". |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
20 The details are in the file \file{Mac/OSX/README}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
21 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
22 As binary installers become available the details will be posted to |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
23 \url{http://www.cwi.nl/\textasciitilde jack/macpython.html}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
24 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
25 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
26 What you get after installing is a number of things: |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
27 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
28 \begin{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
29 \item A \file{MacPython-2.3} folder in your \file{Applications} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
30 folder. In here you find the PythonIDE Integrated Development Environment; |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
31 PythonLauncher, which handles double-clicking Python scripts from |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
32 the Finder; and the Package Manager. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
33 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
34 \item A fairly standard \UNIX{} commandline Python interpreter in |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
35 \file{/usr/local/bin/python}, but without the usual |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
36 \file{/usr/local/lib/python}. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
37 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
38 \item A framework \file{/Library/Frameworks/Python.framework}, where |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
39 all the action really is, but which you usually do not have to be aware of. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
40 \end{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
41 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
42 To uninstall MacPython you can simply remove these three things. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
43 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
44 PythonIDE contains an Apple Help Viewer book called "MacPython Help" |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
45 which you can access through its help menu. If you are completely new to |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
46 Python you should start reading the IDE introduction in that document. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
47 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
48 If you are familiar with Python on other \UNIX{} platforms you should |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
49 read the section on running Python scripts from the \UNIX{} shell. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
50 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
51 \subsection{How to run a Python script} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
52 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
53 Your best way to get started with Python on Mac OS X is through the PythonIDE |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
54 integrated development environment, see section \ref{IDE} and use the Help |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
55 menu when the IDE is running. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
56 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
57 If you want to run Python scripts from the Terminal window command line |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
58 or from the Finder you first need an editor to create your script. |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
59 Mac OS X comes with a number of standard \UNIX{} command line editors, |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
60 \program{vi} and \program{emacs} among them. If you want a more Mac-like |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
61 editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
62 (see \url{http://www.barebones.com/products/bbedit/index.shtml}) are |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
63 good choices. Their freeware \program{BBEdit Lite} is officially |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
64 discontinued but still available. \program{AppleWorks} or any other |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
65 word processor that can save files in ASCII is also a possibility, but |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
66 \program{TextEdit} is not: it saves in \file{.rtf} format only. |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
67 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
68 To run your script from the Terminal window you must make sure that |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
69 \file{/usr/local/bin} is in your shell search path before \file{/usr/bin}, |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
70 where the Apple-supplied Python lives (which is version 2.2, as of Mac OS X |
|
28578
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
71 10.2.4). |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
72 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
73 To run your script from the Finder you have two options: |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
74 \begin{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
75 \item Drag it to \program{PythonLauncher} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
76 \item Select \program{PythonLauncher} as the default application |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
77 to open your script (or any .py script) through the finder Info window |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
78 and double-click it. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
79 \end{itemize} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
80 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
81 PythonLauncher has various preferences to control how your script is launched. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
82 Option-dragging allows you to change these for one invocation, or use its |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
83 Preferences menu to change things globally. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
84 |
|
28578
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
85 \subsection{Running scripts with a GUI \label{osx-gui-scripts}} |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
86 |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
87 There is one Mac OS X quirk that you need to be aware of: programs |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
88 that talk to the Aqua window manager (in other words, anything that has a GUI) |
|
31188
b2a0cd2e9d55
SF #859811, typo in docs
Neal Norwitz <nnorwitz@gmail.com>
parents:
29966
diff
changeset
|
89 need to be run in a special way. Use \program{pythonw} instead of \program{python} |
|
28578
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
90 to start such scripts. |
|
8b49445c0a0e
Moved all the scripting stuff to a separate section, added all the
Jack Jansen <jack.jansen@cwi.nl>
parents:
28546
diff
changeset
|
91 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
92 \subsection{configuration} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
93 |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
94 MacPython honours all standard \UNIX{} environment variables such as |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
95 \envvar{PYTHONPATH}, but setting these variables for programs started |
|
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
96 from the Finder is non-standard |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
97 as the Finder does not read your \file{.profile} or \file{.cshrc} at startup. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
98 You need to create a file \file{\textasciitilde /.MacOSX/environment.plist}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
99 See Apple's Technical Document QA1067 for details. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
100 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
101 Installing additional Python packages is most easily done through the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
102 Package Manager, see the MacPython Help Book for details. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
103 |
|
27833
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
104 \section{Getting and Installing MacPython-OS9 \label{getting}} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
105 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
106 The most recent release version as well as possible newer experimental |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
107 versions are best found at the MacPython page maintained by Jack |
|
29966
fe499bc7381f
Avoid a 301 permanent redirect.
Fred Drake <fdrake@acm.org>
parents:
28578
diff
changeset
|
108 Jansen: \url{http://homepages.cwi.nl/\textasciitilde jack/macpython.html}. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
109 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
110 Please refer to the \file{README} included with your distribution for |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
111 the most up-to-date instructions. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
112 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
113 Note that MacPython-OS9 runs fine on Mac OS X, and it runs in native |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
114 mode, not in the Classic environment. Unless you have specific |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
115 requirements for a CFM-based Python there is no reason not to |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
116 use MacPython-OSX, though. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
117 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
118 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
119 \subsection{Entering the interactive Interpreter |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
120 \label{interpreter}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
121 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
122 The interactive interpreter that you will see used in Python |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
123 documentation is started by double-clicking the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
124 \program{PythonInterpreter} icon, which looks like a 16-ton weight |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
125 falling. You should see the version information and the |
|
17500
5e99a1d0ea4d
Work around the conversion of ">>" and "<<" to guillemets. Reported by Ping.
Fred Drake <fdrake@acm.org>
parents:
15230
diff
changeset
|
126 \samp{>\code{>}>~} prompt. Use it exactly as described in the |
|
5e99a1d0ea4d
Work around the conversion of ">>" and "<<" to guillemets. Reported by Ping.
Fred Drake <fdrake@acm.org>
parents:
15230
diff
changeset
|
127 standard documentation. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
128 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
129 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
130 \subsection{How to run a Python script} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
131 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
132 There are several ways to run an existing Python script; two common |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
133 ways to run a Python script are ``drag and drop'' and ``double |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
134 clicking''. Other ways include running it from within the IDE (see |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
135 Section \ref{IDE}), or launching via AppleScript. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
136 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
137 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
138 \subsubsection{Drag and drop} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
139 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
140 One of the easiest ways to launch a Python script is via ``Drag and |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
141 Drop''. This is just like launching a text file in the Finder by |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
142 ``dragging'' it over your word processor's icon and ``dropping'' it |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
143 there. Make sure that you use an icon referring to the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
144 \program{PythonInterpreter}, not the \program{IDE} or \program{Idle} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
145 icons which have different behaviour which is described below. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
146 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
147 Some things that might have gone wrong: |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
148 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
149 \begin{itemize} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
150 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
151 A window flashes after dropping the script onto the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
152 \program{PythonInterpreter}, but then disappears. Most likely this is a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
153 configuration issue; your \program{PythonInterpreter} is setup to exit |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
154 immediately upon completion, but your script assumes that if it prints |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
155 something that text will stick around for a while. To fix this, see |
|
15230
10b3cbdbdfd9
Fix some internal references that I botched.
Fred Drake <fdrake@acm.org>
parents:
15229
diff
changeset
|
156 section \ref{defaults}. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
157 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
158 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
159 When you waved the script icon over the \program{PythonInterpreter}, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
160 the \program{PythonInterpreter} icon did not hilight. Most likely the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
161 Creator code and document type is unset (or set incorrectly) -- this |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
162 often happens when a file originates on a non-Mac computer. See |
|
15230
10b3cbdbdfd9
Fix some internal references that I botched.
Fred Drake <fdrake@acm.org>
parents:
15229
diff
changeset
|
163 section \ref{creator-code} for more details. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
164 \end{itemize} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
165 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
166 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
167 \subsubsection{Set Creator and Double Click \label{creator-code}} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
168 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
169 If the script that you want to launch has the appropriate Creator Code |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
170 and File Type you can simply double-click on the script to launch it. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
171 To be ``double-clickable'' a file needs to be of type \samp{TEXT}, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
172 with a creator code of \samp{Pyth}. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
173 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
174 Setting the creator code and filetype can be done with the IDE (see |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
175 sections \ref{IDEwrite} and \ref{IDEapplet}), with an editor with a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
176 Python mode (\program{BBEdit}) -- see section |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
177 \ref{scripting-with-BBedit}, or with assorted other Mac utilities, but |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
178 a script (\file{fixfiletypes.py}) has been included in the MacPython |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
179 distribution, making it possible to set the proper Type and Creator |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
180 Codes with Python. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
181 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
182 The \file{fixfiletypes.py} script will change the file type and |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
183 creator codes for the indicated directory. To use |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
184 \file{fixfiletypes.py}: |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
185 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
186 \begin{enumerate} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
187 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
188 Locate it in the \file{scripts} folder of the \file{Mac} folder of the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
189 MacPython distribution. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
190 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
191 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
192 Put all of the scripts that you want to fix in a folder with nothing |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
193 else in it. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
194 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
195 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
196 Double-click on the \file{fixfiletypes.py} icon. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
197 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
198 \item |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
199 Navigate into the folder of files you want to fix, and press the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
200 ``Select current folder'' button. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
201 \end{enumerate} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
202 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
203 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
204 \subsection{Simulating command line arguments |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
205 \label{argv}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
206 |
|
27833
523efd773261
Updated the Mac documentation to the current state of affairs.
Jack Jansen <jack.jansen@cwi.nl>
parents:
25862
diff
changeset
|
207 There are two ways to simulate command-line arguments with MacPython-OS9. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
208 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
209 \begin{enumerate} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
210 \item via Interpreter options |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
211 \begin{itemize} % nestable? I hope so! |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
212 \item Hold the option-key down when launching your script. This will |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
213 bring up a dialog box of Python Interpreter options. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
214 \item Click ``Set \UNIX-style command line..'' button. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
215 \item Type the arguments into the ``Argument'' field. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
216 \item Click ``OK'' |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
217 \item Click ``Run''. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
218 \end{itemize} % end |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
219 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
220 \item via drag and drop |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
221 If you save the script as an applet (see Section \ref{IDEapplet}), you |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
222 can also simulate some command-line arguments via |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
223 ``Drag-and-Drop''. In this case, the names of the files that were |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
224 dropped onto the applet will be appended to \code{sys.argv}, so that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
225 it will appear to the script as though they had been typed on a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
226 command line. As on \UNIX\ systems, the first item in \code{sys.srgv} is |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
227 the path to the applet, and the rest are the files dropped on the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
228 applet. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
229 \end{enumerate} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
230 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
231 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
232 \subsection{Creating a Python script} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
233 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
234 Since Python scripts are simply text files, they can be created in any |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
235 way that text files can be created, but some special tools also exist |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
236 with extra features. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
237 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
238 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
239 \subsubsection{In an editor} |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
240 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
241 You can create a text file with any word processing program such as |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
242 \program{MSWord} or \program{AppleWorks} but you need to make sure |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
243 that the file is saved as ``\ASCII'' or ``plain text''. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
244 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
245 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
246 \subsubsection{Editors with Python modes} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
247 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
248 Several text editors have additional features that add functionality |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
249 when you are creating a Python script. These can include coloring |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
250 Python keywords to make your code easier to read, module browsing, or |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
251 a built-in debugger. These include \program{Alpha}, \program{Pepper}, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
252 and \program{BBedit}, and the MacPython IDE (Section \ref{IDE}). |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
253 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
254 %\subsubsection{Alpha} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
255 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
256 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
257 \subsubsection{BBedit \label{scripting-with-BBedit}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
258 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
259 If you use \program{BBEdit} to create your scripts you will want to tell it about the Python creator code so that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
260 you can simply double click on the saved file to launch it. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
261 \begin{itemize} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
262 \item Launch \program{BBEdit}. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
263 \item Select ``Preferences'' from the ``Edit'' menu. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
264 \item Select ``File Types'' from the scrolling list. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
265 \item click on the ``Add...'' button and navigate to |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
266 \program{PythonInterpreter} in the main directory of the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
267 MacPython distribution; click ``open''. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
268 \item Click on the ``Save'' button in the Preferences panel. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
269 \end{itemize} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
270 % Are there additional BBedit Python-specific features? I'm not aware of any. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
271 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
272 %\subsubsection{IDE} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
273 %You can use the \program{Python IDE} supplied in the MacPython Distribution to create longer Python scripts |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
274 %-- see Section \ref{IDEwrite} for details. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
275 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
276 %\subsubsection{IDLE} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
277 %Idle is an IDE for Python that was written in Python, using TKInter. You should be able to use it on a Mac by following |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
278 %the standard documentation, but see Section \ref{TKInter} for guidance on using TKInter with MacPython. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
279 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
280 %\subsubsection{Pepper} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
281 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
282 |
|
28546
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
283 \subsection{Configuration \label{configuration}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
284 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
285 The MacPython distribution comes with \program{EditPythonPrefs}, an |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
286 applet which will help you to customize the MacPython environment for |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
287 your working habits. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
288 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
289 \subsubsection{EditPythonPrefs\label{EditPythonPrefs}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
290 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
291 \program{EditPythonPrefs} gives you the capability to configure Python |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
292 to behave the way you want it to. There are two ways to use |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
293 \program{EditPythonPrefs}, you can use it to set the preferences in |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
294 general, or you can drop a particular Python engine onto it to |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
295 customize only that version. The latter can be handy if, for example, |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
296 you want to have a second copy of the \program{PythonInterpreter} that |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
297 keeps the output window open on a normal exit even though you prefer |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
298 to normally not work that way. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
299 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
300 To change the default preferences, simply double-click on |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
301 \program{EditPythonPrefs}. To change the preferences only for one copy |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
302 of the Interpreter, drop the icon for that copy onto |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
303 \program{EditPythonPrefs}. You can also use \program{EditPythonPrefs} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
304 in this fashion to set the preferences of the \program{Python IDE} and |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
305 any applets you create -- see section %s \ref{BuildApplet} and |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
306 \ref{IDEapplet}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
307 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
308 \subsubsection{Adding modules to the Module Search Path |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
309 \label{search-path}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
310 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
311 When executing an \keyword{import} statement, Python looks for modules |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
312 in places defined by the \member{sys.path} To edit the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
313 \member{sys.path} on a Mac, launch \program{EditPythonPrefs}, and |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
314 enter them into the largish field at the top (one per line). |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
315 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
316 Since MacPython defines a main Python directory, the easiest thing is |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
317 to add folders to search within the main Python directory. To add a |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
318 folder of scripts that you created called ``My Folder'' located in the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
319 main Python Folder, enter \samp{\$(PYTHON):My Folder} onto a new line. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
320 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
321 To add the Desktop under OS 9 or below, add |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
322 \samp{StartupDriveName:Desktop Folder} on a new line. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
323 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
324 \subsubsection{Default startup options \label{defaults}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
325 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
326 % I'm assuming that there exists some other documentation on the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
327 % rest of the options so I only go over a couple here. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
328 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
329 The ``Default startup options...'' button in the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
330 \program{EditPythonPrefs} dialog box gives you many options including |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
331 the ability to keep the ``Output'' window open after the script |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
332 terminates, and the ability to enter interactive mode after the |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
333 termination of the run script. The latter can be very helpful if you |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
334 want to examine the objects that were created during your script. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
335 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
336 %\section{Nifty Tools} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
337 %There are many other tools included with the MacPython |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
338 %distribution. In addition to those discussed here, make |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
339 %sure to check the \file{Mac} directory. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
340 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
341 %\subsection{BuildApplet \label{BuildApplet}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
342 % **NEED INFO HERE** |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
343 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
344 %\subsection{BuildApplication} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
345 % **NEED INFO HERE** |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
346 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
347 %\section{TKInter on the Mac \label{TKInter}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
348 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
349 %TKinter is installed by default with the MacPython distribution, but |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
350 %you may need to add the \file{lib-tk} folder to the Python Path (see |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
351 %section \ref{search-path}). Also, it is important that you do not |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
352 %try to launch Tk from within the \program{Python IDE} because the two |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
353 %event loops will collide -- always run a script which uses Tkinter |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
354 %with the \program{PythonInterpreter} instead -- see section |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
355 %\ref{interpreter}. |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
356 |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
357 %\section{CGI on the Mac with Python \label{CGI}} |
|
fd434beb5f56
Created a minimal MacOSX section.
Jack Jansen <jack.jansen@cwi.nl>
parents:
27833
diff
changeset
|
358 %**NEED INFO HERE** |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
359 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
360 \section{The IDE\label{IDE}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
361 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
362 The \program{Python IDE} (Integrated Development Environment) is a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
363 separate application that acts as a text editor for your Python code, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
364 a class browser, a graphical debugger, and more. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
365 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
366 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
367 \subsection{Using the ``Python Interactive'' window} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
368 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
369 Use this window like you would the \program{PythonInterpreter}, except |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
370 that you cannot use the ``Drag and drop'' method above. Instead, |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
371 dropping a script onto the \program{Python IDE} icon will open the |
|
20821
ca418a5fa471
Correct misspelling of "separate" in two places.
Fred Drake <fdrake@acm.org>
parents:
17500
diff
changeset
|
372 file in a separate script window (which you can then execute manually |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
373 -- see section \ref{IDEexecution}). |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
374 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
375 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
376 \subsection{Writing a Python Script \label{IDEwrite}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
377 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
378 In addition to using the \program{Python IDE} interactively, you can |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
379 also type out a complete Python program, saving it incrementally, and |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
380 execute it or smaller selections of it. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
381 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
382 You can create a new script, open a previously saved script, and save |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
383 your currently open script by selecting the appropriate item in the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
384 ``File'' menu. Dropping a Python script onto the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
385 \program{Python IDE} will open it for editting. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
386 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
387 If you try to open a script with the \program{Python IDE} but either |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
388 can't locate it from the ``Open'' dialog box, or you get an error |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
389 message like ``Can't open file of type ...'' see section |
|
15230
10b3cbdbdfd9
Fix some internal references that I botched.
Fred Drake <fdrake@acm.org>
parents:
15229
diff
changeset
|
390 \ref{creator-code}. |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
391 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
392 When the \program{Python IDE} saves a script, it uses the creator code |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
393 settings which are available by clicking on the small black triangle |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
394 on the top right of the document window, and selecting ``save |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
395 options''. The default is to save the file with the \program{Python |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
396 IDE} as the creator, this means that you can open the file for editing |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
397 by simply double-clicking on its icon. You might want to change this |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
398 behaviour so that it will be opened by the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
399 \program{PythonInterpreter}, and run. To do this simply choose |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
400 ``Python Interpreter'' from the ``save options''. Note that these |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
401 options are associated with the \emph{file} not the application. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
402 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
403 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
404 \subsection{Executing a script from within the IDE |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
405 \label{IDEexecution}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
406 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
407 You can run the script in the frontmost window of the \program{Python |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
408 IDE} by hitting the run all button. You should be aware, however that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
409 if you use the Python convention \samp{if __name__ == "__main__":} the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
410 script will \emph{not} be ``__main__'' by default. To get that |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
411 behaviour you must select the ``Run as __main__'' option from the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
412 small black triangle on the top right of the document window. Note |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
413 that this option is associated with the \emph{file} not the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
414 application. It \emph{will} stay active after a save, however; to shut |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
415 this feature off simply select it again. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
416 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
417 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
418 \subsection{``Save as'' versus ``Save as Applet'' |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
419 \label{IDEapplet}} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
420 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
421 When you are done writing your Python script you have the option of |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
422 saving it as an ``applet'' (by selecting ``Save as applet'' from the |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
423 ``File'' menu). This has a significant advantage in that you can drop |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
424 files or folders onto it, to pass them to the applet the way |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
425 command-line users would type them onto the command-line to pass them |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
426 as arguments to the script. However, you should make sure to save the |
|
20821
ca418a5fa471
Correct misspelling of "separate" in two places.
Fred Drake <fdrake@acm.org>
parents:
17500
diff
changeset
|
427 applet as a separate file, do not overwrite the script you are |
|
15229
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
428 writing, because you will not be able to edit it again. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
429 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
430 Accessing the items passed to the applet via ``drag-and-drop'' is done |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
431 using the standard \member{sys.argv} mechanism. See the general |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
432 documentation for more |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
433 % need to link to the appropriate place in non-Mac docs |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
434 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
435 Note that saving a script as an applet will not make it runnable on a |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
436 system without a Python installation. |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
437 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
438 %\subsection{Debugger} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
439 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
440 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
441 %\subsection{Module Browser} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
442 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
443 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
444 %\subsection{Profiler} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
445 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
446 % end IDE |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
447 |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
448 %\subsection{The ``Scripts'' menu} |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
449 % **NEED INFO HERE** |
|
bd88df20da2f
Chapter on how to use MacPython, by Bob Savage <bobsavage@mac.com>.
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
450 |
