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