blob: 66187545ef226302f55fd3d39233ec16f9c349d3 [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.
18\end{excdesc}
19
20\begin{funcdesc}{SetHighLevelEventHandler}{handler}
21Pass a python function that will be called upon reception of a
22high-level event. The previous handler is returned. The handler
23function is called with the event as argument.
24
25Note that your event handler is currently only called dependably if
26your main event loop is in \var{stdwin}.
27\end{funcdesc}
28
29\begin{funcdesc}{AcceptHighLevelEvent}{}
30Read a high-level event. The return value is a tuple \code{(sender,
31refcon, data)}.
32\end{funcdesc}
33
34\begin{funcdesc}{SetScheduleTimes}{fgi\, fgy \optional{\, bgi\, bgy}}
35Controls how often the interpreter checks the event queue and how
36long it will yield the processor to other processes. \var{fgi}
37specifies after how many clicks (one click is one 60th of a second)
38the interpreter should check the event queue, and \var{fgy} specifies
39for how many clicks the CPU should be yielded when in the
40foreground. The optional \var{bgi} and \var{bgy} allow you to specify
41different values to use when python runs in the background, otherwise
42the background values will be set the the same as the foreground
43values. The function returns nothing.
44
45The default values, which are based on nothing at all, are 12, 6, 1
46and 12 respectively.
47\end{funcdesc}
48
49\begin{funcdesc}{EnableAppswitch}{onoff}
50Enable or disable the python event loop, based on the value of
51\var{onoff}. The old value is returned. If the event loop is disabled
52no time is granted to other applications, checking for command-period
53is not performed and it is impossible to switch applications. This
54should only be used by programs providing their own complete event
55loop.
56
57Note that based on the compiler used to build python it is still
58possible to loose events even with the python event loop disabled. If
59you have a \code{sys.stdout} window its handler will often also look
60in the event queue. Making sure nothing is ever printed works around
61this.
62\end{funcdesc}
63
64\begin{funcdesc}{HandleEvent}{ev}
65Pass the event record \code{ev} back to the python event loop, or
66possibly to the handler for the \code{sys.stdout} window (based on the
67compiler used to build python). This allows python programs that do
68their own event handling to still have some command-period and
69window-switching capability.
70\end{funcdesc}
71
72\begin{funcdesc}{GetErrorString}{errno}
73Return the textual description of MacOS error code \var{errno}.
74\end{funcdesc}