Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / mac / module-aetools.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="module-aepack.html" />
13<link rel="prev" href="module-gensuitemodule.html" />
14<link rel="parent" href="scripting.html" />
15<link rel="next" href="module-aepack.html" />
16<meta name='aesop' content='information' />
17<title>3.2 aetools -- OSA client support</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="3.1 gensuitemodule "
25 href="module-gensuitemodule.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="3. MacPython OSA Modules"
28 href="scripting.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="3.3 aepack "
31 href="module-aepack.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-gensuitemodule.html">3.1 gensuitemodule </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="scripting.html">3. MacPython OSA Modules</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-aepack.html">3.3 aepack </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION005200000000000000000">
563.2 <tt class="module">aetools</tt> --
57 OSA client support</A>
58</H1>
59
60<P>
61<A NAME="module-aetools"></A>
62<p class="availability">Availability: <span
63 class="platform">Macintosh</span>.</p>
64
65<P>
66The <tt class="module">aetools</tt> module contains the basic functionality
67on which Python AppleScript client support is built. It also
68imports and re-exports the core functionality of the
69<tt class="module">aetypes</tt> and <tt class="module">aepack</tt> modules. The stub packages
70generated by <tt class="module">gensuitemodule</tt> import the relevant
71portions of <tt class="module">aetools</tt>, so usually you do not need to
72import it yourself. The exception to this is when you
73cannot use a generated suite package and need lower-level
74access to scripting.
75
76<P>
77The <tt class="module">aetools</tt> module itself uses the AppleEvent support
78provided by the <tt class="module">Carbon.AE</tt> module. This has one drawback:
79you need access to the window manager, see section <A href="osx-gui-scripts.html#osx-gui-scripts">1.1.2</A>
80for details. This restriction may be lifted in future releases.
81
82<P>
83The <tt class="module">aetools</tt> module defines the following functions:
84
85<P>
86<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
87 <td><nobr><b><tt id='l2h-142' xml:id='l2h-142' class="function">packevent</tt></b>(</nobr></td>
88 <td><var>ae, parameters, attributes</var>)</td></tr></table></dt>
89<dd>
90Stores parameters and attributes in a pre-created <code>Carbon.AE.AEDesc</code>
91object. <code>parameters</code> and <code>attributes</code> are
92dictionaries mapping 4-character OSA parameter keys to Python objects. The
93objects are packed using <code>aepack.pack()</code>.
94</dl>
95
96<P>
97<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
98 <td><nobr><b><tt id='l2h-143' xml:id='l2h-143' class="function">unpackevent</tt></b>(</nobr></td>
99 <td><var>ae</var><big>[</big><var>, formodulename</var><big>]</big><var></var>)</td></tr></table></dt>
100<dd>
101Recursively unpacks a <code>Carbon.AE.AEDesc</code> event to Python objects.
102The function returns the parameter dictionary and the attribute dictionary.
103The <code>formodulename</code> argument is used by generated stub packages to
104control where AppleScript classes are looked up.
105</dl>
106
107<P>
108<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
109 <td><nobr><b><tt id='l2h-144' xml:id='l2h-144' class="function">keysubst</tt></b>(</nobr></td>
110 <td><var>arguments, keydict</var>)</td></tr></table></dt>
111<dd>
112Converts a Python keyword argument dictionary <code>arguments</code> to
113the format required by <code>packevent</code> by replacing the keys,
114which are Python identifiers, by the four-character OSA keys according
115to the mapping specified in <code>keydict</code>. Used by the generated suite
116packages.
117</dl>
118
119<P>
120<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
121 <td><nobr><b><tt id='l2h-145' xml:id='l2h-145' class="function">enumsubst</tt></b>(</nobr></td>
122 <td><var>arguments, key, edict</var>)</td></tr></table></dt>
123<dd>
124If the <code>arguments</code> dictionary contains an entry for <code>key</code>
125convert the value for that entry according to dictionary <code>edict</code>.
126This converts human-readable Python enumeration names to the OSA 4-character
127codes.
128Used by the generated suite
129packages.
130</dl>
131
132<P>
133The <tt class="module">aetools</tt> module defines the following class:
134
135<P>
136<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
137 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-146' xml:id='l2h-146' class="class">TalkTo</tt></b>(</nobr></td>
138 <td><var></var><big>[</big><var>signature=None, start=0, timeout=0</var><big>]</big><var></var>)</td></tr></table></dt>
139<dd>
140
141<P>
142Base class for the proxy used to talk to an application. <code>signature</code>
143overrides the class attribute <code>_signature</code> (which is usually set by subclasses)
144and is the 4-char creator code defining the application to talk to.
145<code>start</code> can be set to true to enable running the application on
146class instantiation. <code>timeout</code> can be specified to change the
147default timeout used while waiting for an AppleEvent reply.
148</dl>
149
150<P>
151<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
152 <td><nobr><b><tt id='l2h-147' xml:id='l2h-147' class="method">_start</tt></b>(</nobr></td>
153 <td><var></var>)</td></tr></table></dt>
154<dd>
155Test whether the application is running, and attempt to start it if not.
156</dl>
157
158<P>
159<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
160 <td><nobr><b><tt id='l2h-148' xml:id='l2h-148' class="method">send</tt></b>(</nobr></td>
161 <td><var>code, subcode</var><big>[</big><var>, parameters, attributes</var><big>]</big><var></var>)</td></tr></table></dt>
162<dd>
163Create the AppleEvent <code>Carbon.AE.AEDesc</code> for the verb with
164the OSA designation <code>code, subcode</code> (which are the usual 4-character
165strings), pack the <code>parameters</code> and <code>attributes</code> into it, send it
166to the target application, wait for the reply, unpack the reply with
167<code>unpackevent</code> and return the reply appleevent, the unpacked return values
168as a dictionary and the return attributes.
169</dl>
170
171<DIV CLASS="navigation">
172<div class='online-navigation'>
173<p></p><hr />
174<table align="center" width="100%" cellpadding="0" cellspacing="2">
175<tr>
176<td class='online-navigation'><a rel="prev" title="3.1 gensuitemodule "
177 href="module-gensuitemodule.html"><img src='../icons/previous.png'
178 border='0' height='32' alt='Previous Page' width='32' /></A></td>
179<td class='online-navigation'><a rel="parent" title="3. MacPython OSA Modules"
180 href="scripting.html"><img src='../icons/up.png'
181 border='0' height='32' alt='Up One Level' width='32' /></A></td>
182<td class='online-navigation'><a rel="next" title="3.3 aepack "
183 href="module-aepack.html"><img src='../icons/next.png'
184 border='0' height='32' alt='Next Page' width='32' /></A></td>
185<td align="center" width="100%">Macintosh Library Modules</td>
186<td class='online-navigation'><a rel="contents" title="Table of Contents"
187 href="contents.html"><img src='../icons/contents.png'
188 border='0' height='32' alt='Contents' width='32' /></A></td>
189<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
190 border='0' height='32' alt='Module Index' width='32' /></a></td>
191<td class='online-navigation'><a rel="index" title="Index"
192 href="genindex.html"><img src='../icons/index.png'
193 border='0' height='32' alt='Index' width='32' /></A></td>
194</tr></table>
195<div class='online-navigation'>
196<b class="navlabel">Previous:</b>
197<a class="sectref" rel="prev" href="module-gensuitemodule.html">3.1 gensuitemodule </A>
198<b class="navlabel">Up:</b>
199<a class="sectref" rel="parent" href="scripting.html">3. MacPython OSA Modules</A>
200<b class="navlabel">Next:</b>
201<a class="sectref" rel="next" href="module-aepack.html">3.3 aepack </A>
202</div>
203</div>
204<hr />
205<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
206</DIV>
207<!--End of Navigation Panel-->
208<ADDRESS>
209See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
210</ADDRESS>
211</BODY>
212</HTML>