blob: 119c2da05b4736db7e884d9f0d16f701c453b2f3 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001:mod:`MacOS` --- Access to Mac OS interpreter features
2======================================================
3
4.. module:: MacOS
5 :platform: Mac
6 :synopsis: Access to Mac OS-specific interpreter features.
Benjamin Peterson23681932008-05-12 21:42:13 +00007 :deprecated:
Georg Brandl8ec7f652007-08-15 14:28:01 +00008
9
10This module provides access to MacOS specific functionality in the Python
11interpreter, such as how the interpreter eventloop functions and the like. Use
12with care.
13
Georg Brandlb44c9f32009-04-27 15:29:26 +000014.. note::
Benjamin Peterson23681932008-05-12 21:42:13 +000015
Georg Brandlb44c9f32009-04-27 15:29:26 +000016 This module has been removed in Python 3.x.
Benjamin Peterson23681932008-05-12 21:42:13 +000017
Georg Brandl8ec7f652007-08-15 14:28:01 +000018Note the capitalization of the module name; this is a historical artifact.
19
20
21.. data:: runtimemodel
22
23 Always ``'macho'``, from Python 2.4 on. In earlier versions of Python the value
24 could also be ``'ppc'`` for the classic Mac OS 8 runtime model or ``'carbon'``
25 for the Mac OS 9 runtime model.
26
27
28.. data:: linkmodel
29
30 The way the interpreter has been linked. As extension modules may be
31 incompatible between linking models, packages could use this information to give
32 more decent error messages. The value is one of ``'static'`` for a statically
33 linked Python, ``'framework'`` for Python in a Mac OS X framework, ``'shared'``
34 for Python in a standard Unix shared library. Older Pythons could also have the
35 value ``'cfm'`` for Mac OS 9-compatible Python.
36
37
38.. exception:: Error
39
40 .. index:: module: macerrors
41
42 This exception is raised on MacOS generated errors, either from functions in
43 this module or from other mac-specific modules like the toolbox interfaces. The
Sandro Tosi98ed08f2012-01-14 16:42:02 +010044 arguments are the integer error code (the :c:data:`OSErr` value) and a textual
Georg Brandl8ec7f652007-08-15 14:28:01 +000045 description of the error code. Symbolic names for all known error codes are
46 defined in the standard module :mod:`macerrors`.
47
48
49.. function:: GetErrorString(errno)
50
51 Return the textual description of MacOS error code *errno*.
52
53
54.. function:: DebugStr(message [, object])
55
56 On Mac OS X the string is simply printed to stderr (on older Mac OS systems more
57 elaborate functionality was available), but it provides a convenient location to
58 attach a breakpoint in a low-level debugger like :program:`gdb`.
59
Ronald Oussoren5640ce22008-06-05 12:58:24 +000060 .. note::
61
62 Not available in 64-bit mode.
63
Georg Brandl8ec7f652007-08-15 14:28:01 +000064
65.. function:: SysBeep()
66
67 Ring the bell.
68
Ronald Oussoren5640ce22008-06-05 12:58:24 +000069 .. note::
70
71 Not available in 64-bit mode.
72
Georg Brandl8ec7f652007-08-15 14:28:01 +000073
74.. function:: GetTicks()
75
76 Get the number of clock ticks (1/60th of a second) since system boot.
77
78
79.. function:: GetCreatorAndType(file)
80
81 Return the file creator and file type as two four-character strings. The *file*
82 parameter can be a pathname or an ``FSSpec`` or ``FSRef`` object.
83
Ronald Oussoren5640ce22008-06-05 12:58:24 +000084 .. note::
Georg Brandlc62ef8b2009-01-03 20:55:06 +000085
Ronald Oussoren5640ce22008-06-05 12:58:24 +000086 It is not possible to use an ``FSSpec`` in 64-bit mode.
87
Georg Brandl8ec7f652007-08-15 14:28:01 +000088
89.. function:: SetCreatorAndType(file, creator, type)
90
91 Set the file creator and file type. The *file* parameter can be a pathname or an
92 ``FSSpec`` or ``FSRef`` object. *creator* and *type* must be four character
93 strings.
94
Ronald Oussoren5640ce22008-06-05 12:58:24 +000095 .. note::
Georg Brandlc62ef8b2009-01-03 20:55:06 +000096
Ronald Oussoren5640ce22008-06-05 12:58:24 +000097 It is not possible to use an ``FSSpec`` in 64-bit mode.
Georg Brandl8ec7f652007-08-15 14:28:01 +000098
99.. function:: openrf(name [, mode])
100
101 Open the resource fork of a file. Arguments are the same as for the built-in
102 function :func:`open`. The object returned has file-like semantics, but it is
103 not a Python file object, so there may be subtle differences.
104
105
106.. function:: WMAvailable()
107
108 Checks whether the current process has access to the window manager. The method
109 will return ``False`` if the window manager is not available, for instance when
110 running on Mac OS X Server or when logged in via ssh, or when the current
111 interpreter is not running from a fullblown application bundle. A script runs
112 from an application bundle either when it has been started with
113 :program:`pythonw` instead of :program:`python` or when running as an applet.
114
Ronald Oussoren5640ce22008-06-05 12:58:24 +0000115.. function:: splash([resourceid])
116
117 Opens a splash screen by resource id. Use resourceid ``0`` to close
118 the splash screen.
119
120 .. note::
121
122 Not available in 64-bit mode.
123