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