<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>9. MacOS --
Access to MacOS interpreter features</TITLE>
<META NAME="description" CONTENT="9. MacOS --
Access to MacOS interpreter features">
<META NAME="keywords" CONTENT="mac">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="mac.css">
<LINK REL="next" HREF="module-macostools.html">
<LINK REL="previous" HREF="module-ic.html">
<LINK REL="up" HREF="contents.html">
<LINK REL="next" HREF="module-macostools.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-macostools.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="node18.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Macintosh Library Modules</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-macostools.html">10. macostools  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="contents.html">Contents</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="node18.html">8.1 IC Objects</A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION002900000000000000000">
9. <tt class=module>MacOS</tt> --
         Access to MacOS interpreter features</A>
</H1>

<P>
  
<p class=availability>Availability: <span
 class=platform>Macintosh</span>.</p>

<P>
This module provides access to MacOS specific functionality in the
Python interpreter, such as how the interpreter eventloop functions
and the like. Use with care.

<P>
Note the capitalisation of the module name, this is a historical
artifact.

<P>
<dl><dt><b><a name="l2h-137"><tt class=exception>Error</tt></a></b>
<dd>
This exception is raised on MacOS generated errors, either from
functions in this module or from other mac-specific modules like the
toolbox interfaces. The arguments are the integer error code (the
<tt class=cdata>OSErr</tt> value) and a textual description of the error code.
Symbolic names for all known error codes are defined in the standard
module <tt class=module>macerrors</tt><a name="l2h-145"></a>.
</dl>

<P>
<dl><dt><b><a name="l2h-138"><tt class=function>SetEventHandler</tt></a></b> (<var>handler</var>)
<dd>
In the inner interpreter loop Python will occasionally check for events,
unless disabled with <tt class=function>ScheduleParams()</tt>. With this function you
can pass a Python event-handler function that will be called if an event
is available. The event is passed as parameter and the function should return
non-zero if the event has been fully processed, otherwise event processing
continues (by passing the event to the console window package, for instance).

<P>
Call <tt class=function>SetEventHandler()</tt> without a parameter to clear the
event handler. Setting an event handler while one is already set is an
error.
</dl>

<P>
<dl><dt><b><a name="l2h-139"><tt class=function>SchedParams</tt></a></b> (<big>[</big><var>doint</var><big>[</big><var>, evtmask</var><big>[</big><var>,
                              besocial</var><big>[</big><var>, interval</var><big>[</big><var>,
                              bgyield</var><big>]</big><big>]</big><big>]</big><big>]</big><big>]</big>)
<dd>
Influence the interpreter inner loop event handling. <var>Interval</var>
specifies how often (in seconds, floating point) the interpreter
should enter the event processing code. When true, <var>doint</var> causes
interrupt (command-dot) checking to be done. <var>evtmask</var> tells the
interpreter to do event processing for events in the mask (redraws,
mouseclicks to switch to other applications, etc). The <var>besocial</var>
flag gives other processes a chance to run. They are granted minimal
runtime when Python is in the foreground and <var>bgyield</var> seconds per
<var>interval</var> when Python runs in the background.

<P>
All parameters are optional, and default to the current value. The return
value of this function is a tuple with the old values of these options.
Initial defaults are that all processing is enabled, checking is done every
quarter second and the CPU is given up for a quarter second when in the
background.
</dl>

<P>
<dl><dt><b><a name="l2h-140"><tt class=function>HandleEvent</tt></a></b> (<var>ev</var>)
<dd>
Pass the event record <var>ev</var> back to the Python event loop, or
possibly to the handler for the <tt>sys.stdout</tt> window (based on the
compiler used to build Python). This allows Python programs that do
their own event handling to still have some command-period and
window-switching capability.

<P>
If you attempt to call this function from an event handler set through
<tt class=function>SetEventHandler()</tt> you will get an exception.
</dl>

<P>
<dl><dt><b><a name="l2h-141"><tt class=function>GetErrorString</tt></a></b> (<var>errno</var>)
<dd>
Return the textual description of MacOS error code <var>errno</var>.
</dl>

<P>
<dl><dt><b><a name="l2h-142"><tt class=function>splash</tt></a></b> (<var>resid</var>)
<dd>
This function will put a splash window
on-screen, with the contents of the DLOG resource specified by
<var>resid</var>. Calling with a zero argument will remove the splash
screen. This function is useful if you want an applet to post a splash screen
early in initialization without first having to load numerous
extension modules.
</dl>

<P>
<dl><dt><b><a name="l2h-143"><tt class=function>DebugStr</tt></a></b> (<var>message </var><big>[</big><var>, object</var><big>]</big>)
<dd>
Drop to the low-level debugger with message <var>message</var>. The
optional <var>object</var> argument is not used, but can easily be
inspected from the debugger.

<P>
Note that you should use this function with extreme care: if no
low-level debugger like MacsBug is installed this call will crash your
system. It is intended mainly for developers of Python extension
modules.
</dl>

<P>
<dl><dt><b><a name="l2h-144"><tt class=function>openrf</tt></a></b> (<var>name </var><big>[</big><var>, mode</var><big>]</big>)
<dd>
Open the resource fork of a file. Arguments are the same as for the
built-in function <tt class=function>open()</tt>. The object returned has file-like
semantics, but it is not a Python file object, so there may be subtle
differences.
</dl><p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-macostools.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="node18.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Macintosh Library Modules</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-macostools.html">10. macostools  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="contents.html">Contents</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="node18.html">8.1 IC Objects</A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
