Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / mac / application-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="mac.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="mac.html" title='Macintosh Library Modules' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="window-objects.html" />
13<link rel="prev" href="module-FrameWork.html" />
14<link rel="parent" href="module-FrameWork.html" />
15<link rel="next" href="window-objects.html" />
16<meta name='aesop' content='information' />
17<title>2.8.1 Application Objects </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="2.8 FrameWork "
25 href="module-FrameWork.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="2.8 FrameWork "
28 href="module-FrameWork.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="2.8.2 Window Objects"
31 href="window-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Macintosh Library Modules</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-FrameWork.html">2.8 FrameWork </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-FrameWork.html">2.8 FrameWork </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="window-objects.html">2.8.2 Window Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION004810000000000000000"></A><A NAME="application-objects"></A>
56<BR>
572.8.1 Application Objects
58</H2>
59
60<P>
61Application objects have the following methods, among others:
62
63<P>
64<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
65 <td><nobr><b><tt id='l2h-109' xml:id='l2h-109' class="method">makeusermenus</tt></b>(</nobr></td>
66 <td><var></var>)</td></tr></table></dt>
67<dd>
68Override this method if you need menus in your application. Append the
69menus to the attribute <tt class="member">menubar</tt>.
70</dl>
71
72<P>
73<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
74 <td><nobr><b><tt id='l2h-110' xml:id='l2h-110' class="method">getabouttext</tt></b>(</nobr></td>
75 <td><var></var>)</td></tr></table></dt>
76<dd>
77Override this method to return a text string describing your
78application. Alternatively, override the <tt class="method">do_about()</tt> method
79for more elaborate ``about'' messages.
80</dl>
81
82<P>
83<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
84 <td><nobr><b><tt id='l2h-111' xml:id='l2h-111' class="method">mainloop</tt></b>(</nobr></td>
85 <td><var></var><big>[</big><var>mask</var><big>[</big><var>, wait</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
86<dd>
87This routine is the main event loop, call it to set your application
88rolling. <var>Mask</var> is the mask of events you want to handle,
89<var>wait</var> is the number of ticks you want to leave to other
90concurrent application (default 0, which is probably not a good
91idea). While raising <var>self</var> to exit the mainloop is still
92supported it is not recommended: call <code>self._quit()</code> instead.
93
94<P>
95The event loop is split into many small parts, each of which can be
96overridden. The default methods take care of dispatching events to
97windows and dialogs, handling drags and resizes, Apple Events, events
98for non-FrameWork windows, etc.
99
100<P>
101In general, all event handlers should return <code>1</code> if the event is fully
102handled and <code>0</code> otherwise (because the front window was not a FrameWork
103window, for instance). This is needed so that update events and such
104can be passed on to other windows like the Sioux console window.
105Calling <tt class="function">MacOS.HandleEvent()</tt> is not allowed within
106<var>our_dispatch</var> or its callees, since this may result in an
107infinite loop if the code is called through the Python inner-loop
108event handler.
109</dl>
110
111<P>
112<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
113 <td><nobr><b><tt id='l2h-112' xml:id='l2h-112' class="method">asyncevents</tt></b>(</nobr></td>
114 <td><var>onoff</var>)</td></tr></table></dt>
115<dd>
116Call this method with a nonzero parameter to enable
117asynchronous event handling. This will tell the inner interpreter loop
118to call the application event handler <var>async_dispatch</var> whenever events
119are available. This will cause FrameWork window updates and the user
120interface to remain working during long computations, but will slow the
121interpreter down and may cause surprising results in non-reentrant code
122(such as FrameWork itself). By default <var>async_dispatch</var> will immediately
123call <var>our_dispatch</var> but you may override this to handle only certain
124events asynchronously. Events you do not handle will be passed to Sioux
125and such.
126
127<P>
128The old on/off value is returned.
129</dl>
130
131<P>
132<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
133 <td><nobr><b><tt id='l2h-113' xml:id='l2h-113' class="method">_quit</tt></b>(</nobr></td>
134 <td><var></var>)</td></tr></table></dt>
135<dd>
136Terminate the running <tt class="method">mainloop()</tt> call at the next convenient
137moment.
138</dl>
139
140<P>
141<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
142 <td><nobr><b><tt id='l2h-114' xml:id='l2h-114' class="method">do_char</tt></b>(</nobr></td>
143 <td><var>c, event</var>)</td></tr></table></dt>
144<dd>
145The user typed character <var>c</var>. The complete details of the event
146can be found in the <var>event</var> structure. This method can also be
147provided in a <code>Window</code> object, which overrides the
148application-wide handler if the window is frontmost.
149</dl>
150
151<P>
152<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
153 <td><nobr><b><tt id='l2h-115' xml:id='l2h-115' class="method">do_dialogevent</tt></b>(</nobr></td>
154 <td><var>event</var>)</td></tr></table></dt>
155<dd>
156Called early in the event loop to handle modeless dialog events. The
157default method simply dispatches the event to the relevant dialog (not
158through the <code>DialogWindow</code> object involved). Override if you
159need special handling of dialog events (keyboard shortcuts, etc).
160</dl>
161
162<P>
163<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
164 <td><nobr><b><tt id='l2h-116' xml:id='l2h-116' class="method">idle</tt></b>(</nobr></td>
165 <td><var>event</var>)</td></tr></table></dt>
166<dd>
167Called by the main event loop when no events are available. The
168null-event is passed (so you can look at mouse position, etc).
169</dl>
170
171<P>
172
173<DIV CLASS="navigation">
174<div class='online-navigation'>
175<p></p><hr />
176<table align="center" width="100%" cellpadding="0" cellspacing="2">
177<tr>
178<td class='online-navigation'><a rel="prev" title="2.8 FrameWork "
179 href="module-FrameWork.html"><img src='../icons/previous.png'
180 border='0' height='32' alt='Previous Page' width='32' /></A></td>
181<td class='online-navigation'><a rel="parent" title="2.8 FrameWork "
182 href="module-FrameWork.html"><img src='../icons/up.png'
183 border='0' height='32' alt='Up One Level' width='32' /></A></td>
184<td class='online-navigation'><a rel="next" title="2.8.2 Window Objects"
185 href="window-objects.html"><img src='../icons/next.png'
186 border='0' height='32' alt='Next Page' width='32' /></A></td>
187<td align="center" width="100%">Macintosh Library Modules</td>
188<td class='online-navigation'><a rel="contents" title="Table of Contents"
189 href="contents.html"><img src='../icons/contents.png'
190 border='0' height='32' alt='Contents' width='32' /></A></td>
191<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
192 border='0' height='32' alt='Module Index' width='32' /></a></td>
193<td class='online-navigation'><a rel="index" title="Index"
194 href="genindex.html"><img src='../icons/index.png'
195 border='0' height='32' alt='Index' width='32' /></A></td>
196</tr></table>
197<div class='online-navigation'>
198<b class="navlabel">Previous:</b>
199<a class="sectref" rel="prev" href="module-FrameWork.html">2.8 FrameWork </A>
200<b class="navlabel">Up:</b>
201<a class="sectref" rel="parent" href="module-FrameWork.html">2.8 FrameWork </A>
202<b class="navlabel">Next:</b>
203<a class="sectref" rel="next" href="window-objects.html">2.8.2 Window Objects</A>
204</div>
205</div>
206<hr />
207<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
208</DIV>
209<!--End of Navigation Panel-->
210<ADDRESS>
211See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
212</ADDRESS>
213</BODY>
214</HTML>