Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 1 | :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 Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 7 | :deprecated: |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 8 | |
| 9 | |
| 10 | This module provides access to MacOS specific functionality in the Python |
| 11 | interpreter, such as how the interpreter eventloop functions and the like. Use |
| 12 | with care. |
| 13 | |
Georg Brandl | b44c9f3 | 2009-04-27 15:29:26 +0000 | [diff] [blame] | 14 | .. note:: |
Benjamin Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 15 | |
Georg Brandl | b44c9f3 | 2009-04-27 15:29:26 +0000 | [diff] [blame] | 16 | This module has been removed in Python 3.x. |
Benjamin Peterson | 2368193 | 2008-05-12 21:42:13 +0000 | [diff] [blame] | 17 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 18 | Note 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 Tosi | 98ed08f | 2012-01-14 16:42:02 +0100 | [diff] [blame] | 44 | arguments are the integer error code (the :c:data:`OSErr` value) and a textual |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 45 | 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 Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 60 | .. note:: |
| 61 | |
| 62 | Not available in 64-bit mode. |
| 63 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 64 | |
| 65 | .. function:: SysBeep() |
| 66 | |
| 67 | Ring the bell. |
| 68 | |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 69 | .. note:: |
| 70 | |
| 71 | Not available in 64-bit mode. |
| 72 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 73 | |
| 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 Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 84 | .. note:: |
Georg Brandl | c62ef8b | 2009-01-03 20:55:06 +0000 | [diff] [blame] | 85 | |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 86 | It is not possible to use an ``FSSpec`` in 64-bit mode. |
| 87 | |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 88 | |
| 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 Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 95 | .. note:: |
Georg Brandl | c62ef8b | 2009-01-03 20:55:06 +0000 | [diff] [blame] | 96 | |
Ronald Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 97 | It is not possible to use an ``FSSpec`` in 64-bit mode. |
Georg Brandl | 8ec7f65 | 2007-08-15 14:28:01 +0000 | [diff] [blame] | 98 | |
| 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 Oussoren | 5640ce2 | 2008-06-05 12:58:24 +0000 | [diff] [blame] | 115 | .. 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 | |