annotate Doc/mac/libmacos.tex @ 4566:6403c94de50d legacy-trunk

Added safeguard against failure in __del__.
author Guido van Rossum <guido@python.org>
date Wed, 27 Nov 1996 19:39:58 +0000
parents 4cef23e1dcca
children 3468ea8645ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2995
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 \section{Built-in Module \sectcode{MacOS}}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2 \bimodindex{MacOS}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 \renewcommand{\indexsubitem}{(in module MacOS)}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 This module provides access to MacOS specific functionality in the
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7 python interpreter, such as how the interpreter eventloop functions
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 and the like. Use with care.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 Note the capitalisation of the module name, this is a historical
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11 artefact.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
13 \begin{excdesc}{Error}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
14 This exception is raised on MacOS generated errors, either from
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
15 functions in this module or from other mac-specific modules like the
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
16 toolbox interfaces. The arguments are the integer error code (the
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
17 \var{OSErr} value) and a textual description of the error code.
4410
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
18 Symbolic names for all known error codes are defined in the standard
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
19 module \var{macerrors}.
2995
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
20 \end{excdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
21
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
22 \begin{funcdesc}{SetHighLevelEventHandler}{handler}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
23 Pass a python function that will be called upon reception of a
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
24 high-level event. The previous handler is returned. The handler
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25 function is called with the event as argument.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27 Note that your event handler is currently only called dependably if
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
28 your main event loop is in \var{stdwin}.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
29 \end{funcdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
30
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
31 \begin{funcdesc}{AcceptHighLevelEvent}{}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
32 Read a high-level event. The return value is a tuple \code{(sender,
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
33 refcon, data)}.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
34 \end{funcdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
35
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
36 \begin{funcdesc}{SetScheduleTimes}{fgi\, fgy \optional{\, bgi\, bgy}}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
37 Controls how often the interpreter checks the event queue and how
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38 long it will yield the processor to other processes. \var{fgi}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
39 specifies after how many clicks (one click is one 60th of a second)
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
40 the interpreter should check the event queue, and \var{fgy} specifies
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
41 for how many clicks the CPU should be yielded when in the
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
42 foreground. The optional \var{bgi} and \var{bgy} allow you to specify
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
43 different values to use when python runs in the background, otherwise
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
44 the background values will be set the the same as the foreground
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
45 values. The function returns nothing.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
46
4410
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
47 The default values, which are based on minimal empirical testing, are 12, 1, 6
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
48 and 2 respectively.
2995
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
49 \end{funcdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
50
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
51 \begin{funcdesc}{EnableAppswitch}{onoff}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
52 Enable or disable the python event loop, based on the value of
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
53 \var{onoff}. The old value is returned. If the event loop is disabled
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
54 no time is granted to other applications, checking for command-period
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
55 is not performed and it is impossible to switch applications. This
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56 should only be used by programs providing their own complete event
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
57 loop.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
59 Note that based on the compiler used to build python it is still
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
60 possible to loose events even with the python event loop disabled. If
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
61 you have a \code{sys.stdout} window its handler will often also look
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
62 in the event queue. Making sure nothing is ever printed works around
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
63 this.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
64 \end{funcdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
65
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
66 \begin{funcdesc}{HandleEvent}{ev}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
67 Pass the event record \code{ev} back to the python event loop, or
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
68 possibly to the handler for the \code{sys.stdout} window (based on the
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
69 compiler used to build python). This allows python programs that do
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
70 their own event handling to still have some command-period and
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
71 window-switching capability.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
72 \end{funcdesc}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
73
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
74 \begin{funcdesc}{GetErrorString}{errno}
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
75 Return the textual description of MacOS error code \var{errno}.
1a8d6c7dd560 Documented MacOS module.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
76 \end{funcdesc}
3758
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
77
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
78 \begin{funcdesc}{splash}{resid}
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
79 This function will put a splash window
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
80 on-screen, with the contents of the DLOG resource specified by
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
81 \code{resid}. Calling with a zero argument will remove the splash
4410
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
82 screen. This function is useful if you want an applet to post a splash screen
3758
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
83 early in initialization without first having to load numerous
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
84 extension modules.
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
85 \end{funcdesc}
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
86
4410
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
87 \begin{funcdesc}{DebugStr}{message \optional{\, object}}
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
88 Drop to the low-level debugger with message \var{message}. The
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
89 optional \var{object} argument is not used, but can easily be
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
90 inspected from the debugger.
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
91
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
92 Note that you should use this function with extreme care: if no
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
93 low-level debugger like MacsBug is installed this call will crash your
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
94 system. It is intended mainly for developers of Python extension
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
95 modules.
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
96 \end{funcdesc}
4cef23e1dcca Patches for Mac module docs by Jack
Guido van Rossum <guido@python.org>
parents: 3758
diff changeset
97
3758
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
98 \begin{funcdesc}{openrf}{name \optional{\, mode}}
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
99 Open the resource fork of a file. Arguments are the same as for the
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
100 builtin function \code{open}. The object returned has file-like
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
101 semantics, but it is not a python file object, so there may be subtle
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
102 differences.
b916d614e363 changes by Jack to Mac docs
Guido van Rossum <guido@python.org>
parents: 2995
diff changeset
103 \end{funcdesc}