diff options
Diffstat (limited to 'Doc/mac')
-rw-r--r-- | Doc/mac/libframework.tex | 3 | ||||
-rw-r--r-- | Doc/mac/libmac.tex | 40 | ||||
-rw-r--r-- | Doc/mac/libmacic.tex | 13 | ||||
-rw-r--r-- | Doc/mac/libmacos.tex | 92 | ||||
-rw-r--r-- | Doc/mac/scripting.tex | 7 | ||||
-rw-r--r-- | Doc/mac/undoc.tex | 74 | ||||
-rw-r--r-- | Doc/mac/using.tex | 356 |
7 files changed, 88 insertions, 497 deletions
diff --git a/Doc/mac/libframework.tex b/Doc/mac/libframework.tex index dc8f99f..e7c38ef 100644 --- a/Doc/mac/libframework.tex +++ b/Doc/mac/libframework.tex @@ -15,7 +15,8 @@ different levels, i.e. to handle clicks in a single dialog window in a non-standard way it is not necessary to override the complete event handling. -The \module{FrameWork} is still very much work-in-progress, and the +Work on the \module{FrameWork} has pretty much stopped, now that +\module{PyObjC} is available for full Cocoa access from Python, and the documentation describes only the most important functionality, and not in the most logical manner at that. Examine the source or the examples for more details. The following are some comments posted on the diff --git a/Doc/mac/libmac.tex b/Doc/mac/libmac.tex index 160753a..9dece8d 100644 --- a/Doc/mac/libmac.tex +++ b/Doc/mac/libmac.tex @@ -1,36 +1,3 @@ -\section{\module{mac} --- - Implementations for the \module{os} module} - -\declaremodule{builtin}{mac} - \platform{Mac} -\modulesynopsis{Implementations for the \module{os} module.} - - -This module implements the Mac OS 9 operating system dependent functionality -provided by the standard module \module{os}\refstmodindex{os}. It is -best accessed through the \module{os} module. This module is only available in -MacPython-OS9, on MacPython-OSX \module{posix} is used. - -The following functions are available in this module: -\function{chdir()}, -\function{close()}, -\function{dup()}, -\function{fdopen()}, -\function{getcwd()}, -\function{lseek()}, -\function{listdir()}, -\function{mkdir()}, -\function{open()}, -\function{read()}, -\function{rename()}, -\function{rmdir()}, -\function{stat()}, -\function{sync()}, -\function{unlink()}, -\function{write()}, -as well as the exception \exception{error}. Note that the times -returned by \function{stat()} are floating-point values, like all time -values in MacPython-OS9. \section{\module{macpath} --- MacOS path manipulation functions} @@ -41,9 +8,10 @@ values in MacPython-OS9. \modulesynopsis{MacOS path manipulation functions.} -This module is the Macintosh implementation of the \module{os.path} -module. It is most portably accessed as -\module{os.path}\refstmodindex{os.path}. Refer to the +This module is the Mac OS 9 (and earlier) implementation of the \module{os.path} +module. It can be used to manipulate old-style Macintosh pathnames on Mac OS +X (or any other platform). +Refer to the \citetitle[../lib/lib.html]{Python Library Reference} for documentation of \module{os.path}. diff --git a/Doc/mac/libmacic.tex b/Doc/mac/libmacic.tex index ad37c10..6d3a0d7 100644 --- a/Doc/mac/libmacic.tex +++ b/Doc/mac/libmacic.tex @@ -6,13 +6,8 @@ \modulesynopsis{Access to Internet Config.} -This module provides access to Macintosh Internet -Config\index{Internet Config} package, -which stores preferences for Internet programs such as mail address, -default homepage, etc. Also, Internet Config contains an elaborate set -of mappings from Macintosh creator/type codes to foreign filename -extensions plus information on how to transfer files (binary, ascii, -etc.). Since MacOS 9, this module is a control panel named Internet. +This module provides access to various internet-related preferences +set through \program{System Preferences} or the \program{Finder}. There is a low-level companion module \module{icglue}\refbimodindex{icglue} which provides the basic @@ -92,7 +87,7 @@ complete incomplete URLs. \begin{methoddesc}{mapfile}{file} Return the mapping entry for the given \var{file}, which can be passed -as either a filename or an \function{macfs.FSSpec()} result, and which +as either a filename or an \function{FSSpec()} result, and which need not exist. The mapping entry is returned as a tuple \code{(\var{version}, @@ -122,7 +117,7 @@ The mapping entry is returned in the same format as for \var{mapfile}. \begin{methoddesc}{settypecreator}{file} Given an existing \var{file}, specified either as a filename or as an -\function{macfs.FSSpec()} result, set its creator and type correctly based +\function{FSSpec()} result, set its creator and type correctly based on its extension. The finder is told about the change, so the finder icon will be updated quickly. \end{methoddesc} diff --git a/Doc/mac/libmacos.tex b/Doc/mac/libmacos.tex index 7b1c79f..b22b39c 100644 --- a/Doc/mac/libmacos.tex +++ b/Doc/mac/libmacos.tex @@ -14,11 +14,10 @@ Note the capitalization of the module name; this is a historical artifact. \begin{datadesc}{runtimemodel} -Either\code{'carbon'} or \code{'macho'}. This -signifies whether this Python uses the Mac OS X and Mac OS 9 compatible -CarbonLib style or the Mac OS -X-only Mach-O style. In earlier versions of Python the value could -also be \code{'ppc'} for the classic Mac OS 8 runtime model. +Always \code{'macho'}, from Python 2.4 on. +In earlier versions of Python the value could +also be \code{'ppc'} for the classic Mac OS 8 runtime model or +\code{'carbon'} for the Mac OS 9 runtime model. \end{datadesc} \begin{datadesc}{linkmodel} @@ -26,8 +25,9 @@ The way the interpreter has been linked. As extension modules may be incompatible between linking models, packages could use this information to give more decent error messages. The value is one of \code{'static'} for a statically linked Python, \code{'framework'} for Python in a Mac OS X framework, -\code{'shared'} for Python in a standard unix shared library and -\code{'cfm'} for the Mac OS 9-compatible Python. +\code{'shared'} for Python in a standard unix shared library. +Older Pythons could also have the value +\code{'cfm'} for Mac OS 9-compatible Python. \end{datadesc} \begin{excdesc}{Error} @@ -39,84 +39,16 @@ Symbolic names for all known error codes are defined in the standard module \refmodule{macerrors}.\refstmodindex{macerrors} \end{excdesc} -\begin{funcdesc}{SetEventHandler}{handler} -In the inner interpreter loop Python will occasionally check for events, -unless disabled with \function{ScheduleParams()}. With this function you -can pass a Python event-handler function that will be called if an event -is available. The event is passed as parameter and the function should return -non-zero if the event has been fully processed, otherwise event processing -continues (by passing the event to the console window package, for instance). - -Call \function{SetEventHandler()} without a parameter to clear the -event handler. Setting an event handler while one is already set is an -error. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{SchedParams}{\optional{doint\optional{, evtmask\optional{, - besocial\optional{, interval\optional{, - bgyield}}}}}} -Influence the interpreter inner loop event handling. \var{Interval} -specifies how often (in seconds, floating point) the interpreter -should enter the event processing code. When true, \var{doint} causes -interrupt (command-dot) checking to be done. \var{evtmask} tells the -interpreter to do event processing for events in the mask (redraws, -mouseclicks to switch to other applications, etc). The \var{besocial} -flag gives other processes a chance to run. They are granted minimal -runtime when Python is in the foreground and \var{bgyield} seconds per -\var{interval} when Python runs in the background. - -All parameters are optional, and default to the current value. The return -value of this function is a tuple with the old values of these options. -Initial defaults are that all processing is enabled, checking is done every -quarter second and the processor is given up for a quarter second when in the -background. - -The most common use case is to call \code{SchedParams(0, 0)} to completely disable -event handling in the interpreter mainloop. - -Availability: MacPython-OS9. -\end{funcdesc} - -\begin{funcdesc}{HandleEvent}{ev} -Pass the event record \var{ev} back to the Python event loop, or -possibly to the handler for the \code{sys.stdout} window (based on the -compiler used to build Python). This allows Python programs that do -their own event handling to still have some command-period and -window-switching capability. - -If you attempt to call this function from an event handler set through -\function{SetEventHandler()} you will get an exception. - -Availability: MacPython-OS9. -\end{funcdesc} \begin{funcdesc}{GetErrorString}{errno} Return the textual description of MacOS error code \var{errno}. \end{funcdesc} -\begin{funcdesc}{splash}{resid} -This function will put a splash window -on-screen, with the contents of the DLOG resource specified by -\var{resid}. Calling with a zero argument will remove the splash -screen. This function is useful if you want an applet to post a splash screen -early in initialization without first having to load numerous -extension modules. - -Availability: MacPython-OS9. -\end{funcdesc} - \begin{funcdesc}{DebugStr}{message \optional{, object}} -On Mac OS 9, drop to the low-level debugger with message \var{message}. The -optional \var{object} argument is not used, but can easily be -inspected from the debugger. On Mac OS X the string is simply printed -to stderr. - -Note that you should use this function with extreme care: if no -low-level debugger like MacsBug is installed this call will crash your -system. It is intended mainly for developers of Python extension -modules. +On Mac OS X the string is simply printed to stderr (on older +Mac OS systems more elaborate functionality was available), +but it provides a convenient location to attach a breakpoint +in a low-level debugger like \program{gdb}. \end{funcdesc} \begin{funcdesc}{SysBeep}{} @@ -155,6 +87,4 @@ or when the current interpreter is not running from a fullblown application bundle. A script runs from an application bundle either when it has been started with \program{pythonw} instead of \program{python} or when running as an applet. - -On Mac OS 9 the method always returns \code{True}. \end{funcdesc} diff --git a/Doc/mac/scripting.tex b/Doc/mac/scripting.tex index 5ef7612..a6d5df7 100644 --- a/Doc/mac/scripting.tex +++ b/Doc/mac/scripting.tex @@ -1,9 +1,10 @@ \chapter{MacPython OSA Modules \label{scripting}} -Python has a fairly complete implementation of the Open Scripting -Architecture (OSA, also commonly referred to as AppleScript), allowing +This chapter describes the current implementation of the Open Scripting +Architecure (OSA, also commonly referred to as AppleScript) for Python, allowing you to control scriptable applications from your Python program, -and with a fairly pythonic interface. +and with a fairly pythonic interface. Development on this set of modules +has stopped, and a replacement is expected for Python 2.5. For a description of the various components of AppleScript and OSA, and to get an understanding of the architecture and terminology, you should diff --git a/Doc/mac/undoc.tex b/Doc/mac/undoc.tex index cf96593..63a4dbd 100644 --- a/Doc/mac/undoc.tex +++ b/Doc/mac/undoc.tex @@ -21,17 +21,7 @@ touch with \modulesynopsis{Helper module for BuildApplet, BuildApplication and macfreeze.} - -\section{\module{py_resource} --- Resources from Python code} -\declaremodule[pyresource]{standard}{py_resource} - \platform{Mac} -\modulesynopsis{Helper to create \texttt{'PYC~'} resources for compiled - applications.} - -This module is primarily used as a help module for -\program{BuildApplet} and \program{BuildApplication}. It is able to -store compiled Python code as \texttt{'PYC~'} resources in a file. - +\deprecated{2.4} \section{\module{cfmfile} --- Code Fragment Resource module} \declaremodule{standard}{cfmfile} @@ -43,6 +33,7 @@ accompanying ``cfrg'' resources. It can parse them and merge them, and is used by BuildApplication to combine all plugin modules to a single executable. +\deprecated{2.4} \section{\module{icopen} --- Internet Config replacement for \method{open()}} \declaremodule{standard}{icopen} @@ -79,30 +70,6 @@ script is run under MacPython, as a MacPython applet or under OSX Python. A low-level interface to Navigation Services. -\section{\module{mkcwproject} --- Create CodeWarrior projects} -\declaremodule{standard}{mkcwproject} - \platform{Mac} -\modulesynopsis{Create CodeWarrior projects.} - -\refmodindex{distutils} -\module{mkcwproject} creates project files for the Metrowerks CodeWarrior -development environment. It is a helper module for -\module{distutils} but can be used separately for more -control. - - -\section{\module{nsremote} --- Wrapper around Netscape OSA modules} -\declaremodule{standard}{nsremote} - \platform{Mac} -\modulesynopsis{Wrapper around Netscape OSA modules.} - -\module{nsremote} is a wrapper around the Netscape OSA modules that -allows you to easily send your browser to a given URL. A related -module that may be of interest is the \module{webbrowser} module, -documented in the \citetitle[../lib/lib.html]{Python Library -Reference}. - - \section{\module{PixMapWrapper} --- Wrapper for PixMap objects} \declaremodule{standard}{PixMapWrapper} \platform{Mac} @@ -112,43 +79,6 @@ Reference}. allows access to the fields by name. It also has methods to convert to and from \module{PIL} images. - -\section{\module{preferences} --- Application preferences manager} -\declaremodule{standard}{preferences} - \platform{Mac} -\modulesynopsis{Nice application preferences manager with support for - defaults.} - -The \module{preferences} module allows storage of user preferences in -the system-wide preferences folder, with defaults coming from the -application itself and the possibility to override preferences for -specific situations. - - -\section{\module{pythonprefs} --- Preferences manager for Python} -\declaremodule{standard}{pythonprefs} - \platform{Mac} -\modulesynopsis{Specialized preferences manager for the Python - interpreter.} - -This module is a specialization of the \refmodule{preferences} module -that allows reading and writing of the preferences for the Python -interpreter. - - -\section{\module{quietconsole} --- Non-visible standard output} -\declaremodule{standard}{quietconsole} - \platform{Mac} -\modulesynopsis{Buffered, non-visible standard output.} - -\module{quietconsole} allows you to keep stdio output in a buffer -without displaying it (or without displaying the stdout window -altogether, if set with \program{EditPythonPrefs}) until you try to read from -stdin or disable the buffering, at which point all the saved output is -sent to the window. Good for programs with graphical user interfaces -that do want to display their output at a crash. - - \section{\module{videoreader} --- Read QuickTime movies} \declaremodule{standard}{videoreader} \platform{Mac} diff --git a/Doc/mac/using.tex b/Doc/mac/using.tex index 79547c1..bfa478e 100644 --- a/Doc/mac/using.tex +++ b/Doc/mac/using.tex @@ -1,27 +1,25 @@ -\chapter{Using Python on a Mac OS 9 Macintosh \label{using}} +\chapter{Using Python on a Macintosh \label{using}} \sectionauthor{Bob Savage}{bobsavage@mac.com} -Using Python on a Macintosh, especially on Mac OS 9 (MacPython-OSX -includes a complete \UNIX{} Python) can seem like something completely -different than using it on a \UNIX-like or Windows system. Most of the -Python documentation, both the ``official'' documentation and published -books, describe only how Python is used on these systems, causing -confusion for the new user of MacPython-OS9. This chapter gives a brief -introduction to the specifics of using Python on a Macintosh. +Python on a Macintosh running Mac OS X is in principle very similar to +Python on any other \UNIX platform, but there are a number of additional +features such as the IDE and the Package Manager that are worth pointing out. +Python on Mac OS 9 or earlier can be quite different from Python on +Unix or Windows, but is beyond the scope of this manual, as that platform +is no longer supported, starting with Python 2.4. See +\url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers +for the latest 2.3 release for Mac OS 9 and related documentation. -The section on the IDE (see Section \ref{IDE}) is relevant to MacPython-OSX -too. +\section{Getting and Installing MacPython \label{getting-OSX}} -\section{Getting and Installing MacPython-OSX \label{getting-OSX}} - -As of Python 2.3a2 the only sure way of getting MacPython-OSX on your machine -is getting a source distribution and building what is called a "framework Python". -The details are in the file \file{Mac/OSX/README}. - -As binary installers become available the details will be posted to -\url{http://www.cwi.nl/\textasciitilde jack/macpython.html}. +Mac OS X 10.3 comes with Python 2.3 pre-installed by Apple. +This installation does not come with the IDE and other additions, however, +so to get these you need to install the \program{MacPython for Panther additions} +from the MacPython website, \url{http://www.cwi.nl/\textasciitilde jack/macpython}. +For MacPython 2.4, or for any MacPython on earlier releases of Mac OS X, +you need to install a full distribution from the same website. What you get after installing is a number of things: @@ -41,6 +39,14 @@ What you get after installing is a number of things: To uninstall MacPython you can simply remove these three things. +If you use the ``additions'' installer to install on top of an existing +Apple-Python you will not get the framework and the commandline interpreter, +as they have been installed by Apple already, in +\file{/System/Library/Frameworks/Python.framework} and +\file{/usr/bin/python}, respectively. You should in principle never modify +or delete these, as they are Apple-controlled and may be used by Apple- or +third-party software. + PythonIDE contains an Apple Help Viewer book called "MacPython Help" which you can access through its help menu. If you are completely new to Python you should start reading the IDE introduction in that document. @@ -57,18 +63,15 @@ menu when the IDE is running. If you want to run Python scripts from the Terminal window command line or from the Finder you first need an editor to create your script. Mac OS X comes with a number of standard \UNIX{} command line editors, -\program{vi} and \program{emacs} among them. If you want a more Mac-like +\program{vim} and \program{emacs} among them. If you want a more Mac-like editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software (see \url{http://www.barebones.com/products/bbedit/index.shtml}) are -good choices. Their freeware \program{BBEdit Lite} is officially -discontinued but still available. \program{AppleWorks} or any other +good choices. \program{AppleWorks} or any other word processor that can save files in ASCII is also a possibility, including \program{TextEdit} which is included with OS X. To run your script from the Terminal window you must make sure that -\file{/usr/local/bin} is in your shell search path before \file{/usr/bin}, -where the Apple-supplied Python lives (which is version 2.2, as of Mac OS X -10.2.4). +\file{/usr/local/bin} is in your shell search path. To run your script from the Finder you have two options: \begin{itemize} @@ -101,263 +104,6 @@ See Apple's Technical Document QA1067 for details. Installing additional Python packages is most easily done through the Package Manager, see the MacPython Help Book for details. -\section{Getting and Installing MacPython-OS9 \label{getting}} - -The most recent release version as well as possible newer experimental -versions are best found at the MacPython page maintained by Jack -Jansen: \url{http://homepages.cwi.nl/\textasciitilde jack/macpython.html}. - -Please refer to the \file{README} included with your distribution for -the most up-to-date instructions. - -Note that MacPython-OS9 runs fine on Mac OS X, and it runs in native -mode, not in the Classic environment. Unless you have specific -requirements for a CFM-based Python there is no reason not to -use MacPython-OSX, though. - - -\subsection{Entering the interactive Interpreter - \label{interpreter}} - -The interactive interpreter that you will see used in Python -documentation is started by double-clicking the -\program{PythonInterpreter} icon, which looks like a 16-ton weight -falling. You should see the version information and the -\samp{>\code{>}>~} prompt. Use it exactly as described in the -standard documentation. - - -\subsection{How to run a Python script} - -There are several ways to run an existing Python script; two common -ways to run a Python script are ``drag and drop'' and ``double -clicking''. Other ways include running it from within the IDE (see -Section \ref{IDE}), or launching via AppleScript. - - -\subsubsection{Drag and drop} - -One of the easiest ways to launch a Python script is via ``Drag and -Drop''. This is just like launching a text file in the Finder by -``dragging'' it over your word processor's icon and ``dropping'' it -there. Make sure that you use an icon referring to the -\program{PythonInterpreter}, not the \program{IDE} or \program{Idle} -icons which have different behaviour which is described below. - -Some things that might have gone wrong: - -\begin{itemize} -\item -A window flashes after dropping the script onto the -\program{PythonInterpreter}, but then disappears. Most likely this is a -configuration issue; your \program{PythonInterpreter} is setup to exit -immediately upon completion, but your script assumes that if it prints -something that text will stick around for a while. To fix this, see -section \ref{defaults}. - -\item -When you waved the script icon over the \program{PythonInterpreter}, -the \program{PythonInterpreter} icon did not highlight. Most likely -the Creator code and document type is unset (or set incorrectly) -- -this often happens when a file originates on a non-Mac computer. See -section \ref{creator-code} for more details. -\end{itemize} - - -\subsubsection{Set Creator and Double Click \label{creator-code}} - -If the script that you want to launch has the appropriate Creator Code -and File Type you can simply double-click on the script to launch it. -To be ``double-clickable'' a file needs to be of type \samp{TEXT}, -with a creator code of \samp{Pyth}. - -Setting the creator code and filetype can be done with the IDE (see -sections \ref{IDEwrite} and \ref{IDEapplet}), with an editor with a -Python mode (\program{BBEdit}) -- see section -\ref{scripting-with-BBedit}, or with assorted other Mac utilities, but -a script (\file{fixfiletypes.py}) has been included in the MacPython -distribution, making it possible to set the proper Type and Creator -Codes with Python. - -The \file{fixfiletypes.py} script will change the file type and -creator codes for the indicated directory. To use -\file{fixfiletypes.py}: - -\begin{enumerate} -\item -Locate it in the \file{scripts} folder of the \file{Mac} folder of the -MacPython distribution. - -\item -Put all of the scripts that you want to fix in a folder with nothing -else in it. - -\item -Double-click on the \file{fixfiletypes.py} icon. - -\item -Navigate into the folder of files you want to fix, and press the -``Select current folder'' button. -\end{enumerate} - - -\subsection{Simulating command line arguments - \label{argv}} - -There are two ways to simulate command-line arguments with MacPython-OS9. - -\begin{enumerate} -\item via Interpreter options -\begin{itemize} % nestable? I hope so! - \item Hold the option-key down when launching your script. This will - bring up a dialog box of Python Interpreter options. - \item Click ``Set \UNIX-style command line..'' button. - \item Type the arguments into the ``Argument'' field. - \item Click ``OK'' - \item Click ``Run''. -\end{itemize} % end - -\item via drag and drop -If you save the script as an applet (see Section \ref{IDEapplet}), you -can also simulate some command-line arguments via -``Drag-and-Drop''. In this case, the names of the files that were -dropped onto the applet will be appended to \code{sys.argv}, so that -it will appear to the script as though they had been typed on a -command line. As on \UNIX\ systems, the first item in \code{sys.srgv} is -the path to the applet, and the rest are the files dropped on the -applet. -\end{enumerate} - - -\subsection{Creating a Python script} - -Since Python scripts are simply text files, they can be created in any -way that text files can be created, but some special tools also exist -with extra features. - - -\subsubsection{In an editor} - -You can create a text file with any word processing program such as -\program{MSWord} or \program{AppleWorks} but you need to make sure -that the file is saved as ``\ASCII'' or ``plain text''. This also -works for \program{TextEdit}, but you need to use the command ``Make Plain Text`` -in the ``Format`` menu before trying to save. - - -\subsubsection{Editors with Python modes} - -Several text editors have additional features that add functionality -when you are creating a Python script. These can include coloring -Python keywords to make your code easier to read, module browsing, or -a built-in debugger. These include \program{Alpha}, \program{Pepper}, -and \program{BBedit}, and the MacPython IDE (Section \ref{IDE}). - -%\subsubsection{Alpha} -% **NEED INFO HERE** - -\subsubsection{BBedit \label{scripting-with-BBedit}} - -If you use \program{BBEdit} to create your scripts you will want to tell it about the Python creator code so that -you can simply double click on the saved file to launch it. -\begin{itemize} - \item Launch \program{BBEdit}. - \item Select ``Preferences'' from the ``Edit'' menu. - \item Select ``File Types'' from the scrolling list. - \item click on the ``Add...'' button and navigate to - \program{PythonInterpreter} in the main directory of the - MacPython distribution; click ``open''. - \item Click on the ``Save'' button in the Preferences panel. -\end{itemize} -% Are there additional BBedit Python-specific features? I'm not aware of any. - -%\subsubsection{IDE} -%You can use the \program{Python IDE} supplied in the MacPython Distribution to create longer Python scripts -%-- see Section \ref{IDEwrite} for details. - -%\subsubsection{IDLE} -%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 -%the standard documentation, but see Section \ref{TKInter} for guidance on using TKInter with MacPython. - -%\subsubsection{Pepper} -% **NEED INFO HERE** - -\subsection{Configuration \label{configuration}} - -The MacPython distribution comes with \program{EditPythonPrefs}, an -applet which will help you to customize the MacPython environment for -your working habits. - -\subsubsection{EditPythonPrefs\label{EditPythonPrefs}} - -\program{EditPythonPrefs} gives you the capability to configure Python -to behave the way you want it to. There are two ways to use -\program{EditPythonPrefs}, you can use it to set the preferences in -general, or you can drop a particular Python engine onto it to -customize only that version. The latter can be handy if, for example, -you want to have a second copy of the \program{PythonInterpreter} that -keeps the output window open on a normal exit even though you prefer -to normally not work that way. - -To change the default preferences, simply double-click on -\program{EditPythonPrefs}. To change the preferences only for one copy -of the Interpreter, drop the icon for that copy onto -\program{EditPythonPrefs}. You can also use \program{EditPythonPrefs} -in this fashion to set the preferences of the \program{Python IDE} and -any applets you create -- see section %s \ref{BuildApplet} and -\ref{IDEapplet}. - -\subsubsection{Adding modules to the Module Search Path - \label{search-path}} - -When executing an \keyword{import} statement, Python looks for modules -in places defined by the \member{sys.path} To edit the -\member{sys.path} on a Mac, launch \program{EditPythonPrefs}, and -enter them into the largish field at the top (one per line). - -Since MacPython defines a main Python directory, the easiest thing is -to add folders to search within the main Python directory. To add a -folder of scripts that you created called ``My Folder'' located in the -main Python Folder, enter \samp{\$(PYTHON):My Folder} onto a new line. - -To add the Desktop under OS 9 or below, add -\samp{StartupDriveName:Desktop Folder} on a new line. - -\subsubsection{Default startup options \label{defaults}} - -% I'm assuming that there exists some other documentation on the -% rest of the options so I only go over a couple here. - -The ``Default startup options...'' button in the -\program{EditPythonPrefs} dialog box gives you many options including -the ability to keep the ``Output'' window open after the script -terminates, and the ability to enter interactive mode after the -termination of the run script. The latter can be very helpful if you -want to examine the objects that were created during your script. - -%\section{Nifty Tools} -%There are many other tools included with the MacPython -%distribution. In addition to those discussed here, make -%sure to check the \file{Mac} directory. - -%\subsection{BuildApplet \label{BuildApplet}} -% **NEED INFO HERE** - -%\subsection{BuildApplication} -% **NEED INFO HERE** - -%\section{TKInter on the Mac \label{TKInter}} - -%TKinter is installed by default with the MacPython distribution, but -%you may need to add the \file{lib-tk} folder to the Python Path (see -%section \ref{search-path}). Also, it is important that you do not -%try to launch Tk from within the \program{Python IDE} because the two -%event loops will collide -- always run a script which uses Tkinter -%with the \program{PythonInterpreter} instead -- see section -%\ref{interpreter}. - -%\section{CGI on the Mac with Python \label{CGI}} -%**NEED INFO HERE** \section{The IDE\label{IDE}} @@ -365,15 +111,13 @@ The \program{Python IDE} (Integrated Development Environment) is a separate application that acts as a text editor for your Python code, a class browser, a graphical debugger, and more. +The online Python Help contains a quick walkthrough of the IDE that +shows the major features and how to use them. \subsection{Using the ``Python Interactive'' window} -Use this window like you would the \program{PythonInterpreter}, except -that you cannot use the ``Drag and drop'' method above. Instead, -dropping a script onto the \program{Python IDE} icon will open the -file in a separate script window (which you can then execute manually --- see section \ref{IDEexecution}). - +Use this window like you would use a normal \UNIX{} command line +interpreter. \subsection{Writing a Python Script \label{IDEwrite}} @@ -386,11 +130,6 @@ your currently open script by selecting the appropriate item in the ``File'' menu. Dropping a Python script onto the \program{Python IDE} will open it for editing. -If you try to open a script with the \program{Python IDE} but either -can't locate it from the ``Open'' dialog box, or you get an error -message like ``Can't open file of type ...'' see section -\ref{creator-code}. - When the \program{Python IDE} saves a script, it uses the creator code settings which are available by clicking on the small black triangle on the top right of the document window, and selecting ``save @@ -398,8 +137,8 @@ options''. The default is to save the file with the \program{Python IDE} as the creator, this means that you can open the file for editing by simply double-clicking on its icon. You might want to change this behaviour so that it will be opened by the -\program{PythonInterpreter}, and run. To do this simply choose -``Python Interpreter'' from the ``save options''. Note that these +\program{PythonLauncher}, and run. To do this simply choose +``PythonLauncher'' from the ``save options''. Note that these options are associated with the \emph{file} not the application. @@ -449,4 +188,31 @@ system without a Python installation. %\subsection{The ``Scripts'' menu} % **NEED INFO HERE** - + +\section{The Package Manager} + +Historically MacPython came with a number of useful extension packages +included, because most Macintosh users do not have access to a development +environment and C compiler. For Mac OS X that bundling is no longer done, +but a new mechanism has been made available to allow easy access to +extension packages. + +The Python Package Manager helps you installing additional packages +that enhance Python. It determines the exact MacOS version and Python +version you have and uses that information to download a database that +has packages that are tested and tried on that combination. In other +words: if something is in your Package Manager window but does not work +you are free to blame the database maintainer. + +PackageManager then checks which of the packages you have installed and +which ones are not. This should also work when you have installed packages +outside of PackageManager. You can select packages and install them, +and PackageManager will work out the requirements and install these too. + +Often PackageManager will list a package in two flavors: binary and +source. Binary should always work, source will only work if you have +installed the Apple Developer Tools. PackageManager will warn you about +this, and also about other external dependencies. + +PackageManager is available as a separate application and also as a +function of the IDE, through the File->Package Manager menu entry. |