~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.12-docs-html/library/aetools.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>38.2. aetools — OSA client support &mdash; Python 2.7.12 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '2.7.12',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 2.7.12 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 2.7.12 documentation" href="../contents.html" />
 
33
    <link rel="up" title="38. MacPython OSA Modules" href="macosa.html" />
 
34
    <link rel="next" title="38.3. aepack — Conversion between Python variables and AppleEvent data containers" href="aepack.html" />
 
35
    <link rel="prev" title="38.1. gensuitemodule — Generate OSA stub packages" href="gensuitemodule.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
38
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
39
 
 
40
    
 
41
 
 
42
  </head>
 
43
  <body role="document">  
 
44
    <div class="related" role="navigation" aria-label="related navigation">
 
45
      <h3>Navigation</h3>
 
46
      <ul>
 
47
        <li class="right" style="margin-right: 10px">
 
48
          <a href="../genindex.html" title="General Index"
 
49
             accesskey="I">index</a></li>
 
50
        <li class="right" >
 
51
          <a href="../py-modindex.html" title="Python Module Index"
 
52
             >modules</a> |</li>
 
53
        <li class="right" >
 
54
          <a href="aepack.html" title="38.3. aepack — Conversion between Python variables and AppleEvent data containers"
 
55
             accesskey="N">next</a> |</li>
 
56
        <li class="right" >
 
57
          <a href="gensuitemodule.html" title="38.1. gensuitemodule — Generate OSA stub packages"
 
58
             accesskey="P">previous</a> |</li>
 
59
        <li><img src="../_static/py.png" alt=""
 
60
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
61
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
62
        <li>
 
63
          <span class="version_switcher_placeholder">2.7.12</span>
 
64
          <a href="../index.html">Documentation</a> &raquo;
 
65
        </li>
 
66
 
 
67
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
68
          <li class="nav-item nav-item-2"><a href="macosa.html" accesskey="U">38. MacPython OSA Modules</a> &raquo;</li> 
 
69
      </ul>
 
70
    </div>    
 
71
 
 
72
    <div class="document">
 
73
      <div class="documentwrapper">
 
74
        <div class="bodywrapper">
 
75
          <div class="body" role="main">
 
76
            
 
77
  <div class="section" id="module-aetools">
 
78
<span id="aetools-osa-client-support"></span><h1>38.2. <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a> &#8212; OSA client support<a class="headerlink" href="#module-aetools" title="Permalink to this headline">¶</a></h1>
 
79
<p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a> module contains the basic functionality on which Python
 
80
AppleScript client support is built. It also imports and re-exports the core
 
81
functionality of the <a class="reference internal" href="aetypes.html#module-aetypes" title="aetypes: Python representation of the Apple Event Object Model. (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetypes</span></code></a> and <a class="reference internal" href="aepack.html#module-aepack" title="aepack: Conversion between Python variables and AppleEvent data containers. (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aepack</span></code></a> modules. The stub packages
 
82
generated by <a class="reference internal" href="gensuitemodule.html#module-gensuitemodule" title="gensuitemodule: Create a stub package from an OSA dictionary (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">gensuitemodule</span></code></a> import the relevant portions of
 
83
<a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a>, so usually you do not need to import it yourself. The exception
 
84
to this is when you cannot use a generated suite package and need lower-level
 
85
access to scripting.</p>
 
86
<p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a> module itself uses the AppleEvent support provided by the
 
87
<a class="reference internal" href="carbon.html#module-Carbon.AE" title="Carbon.AE: Interface to the Apple Events toolbox. (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">Carbon.AE</span></code></a> module. This has one drawback: you need access to the window
 
88
manager, see section <a class="reference internal" href="../using/mac.html#osx-gui-scripts"><span>Running scripts with a GUI</span></a> for details. This restriction may be
 
89
lifted in future releases.</p>
 
90
<div class="admonition note">
 
91
<p class="first admonition-title">Note</p>
 
92
<p class="last">This module has been removed in Python 3.x.</p>
 
93
</div>
 
94
<p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a> module defines the following functions:</p>
 
95
<dl class="function">
 
96
<dt id="aetools.packevent">
 
97
<code class="descclassname">aetools.</code><code class="descname">packevent</code><span class="sig-paren">(</span><em>ae</em>, <em>parameters</em>, <em>attributes</em><span class="sig-paren">)</span><a class="headerlink" href="#aetools.packevent" title="Permalink to this definition">¶</a></dt>
 
98
<dd><p>Stores parameters and attributes in a pre-created <code class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></code> object.
 
99
<code class="docutils literal"><span class="pre">parameters</span></code> and <code class="docutils literal"><span class="pre">attributes</span></code> are  dictionaries mapping 4-character OSA
 
100
parameter keys to Python objects. The objects are packed using
 
101
<code class="docutils literal"><span class="pre">aepack.pack()</span></code>.</p>
 
102
</dd></dl>
 
103
 
 
104
<dl class="function">
 
105
<dt id="aetools.unpackevent">
 
106
<code class="descclassname">aetools.</code><code class="descname">unpackevent</code><span class="sig-paren">(</span><em>ae</em><span class="optional">[</span>, <em>formodulename</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#aetools.unpackevent" title="Permalink to this definition">¶</a></dt>
 
107
<dd><p>Recursively unpacks a <code class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></code> event to Python objects. The function
 
108
returns the parameter dictionary and the attribute dictionary. The
 
109
<code class="docutils literal"><span class="pre">formodulename</span></code> argument is used by generated stub packages to control where
 
110
AppleScript classes are looked up.</p>
 
111
</dd></dl>
 
112
 
 
113
<dl class="function">
 
114
<dt id="aetools.keysubst">
 
115
<code class="descclassname">aetools.</code><code class="descname">keysubst</code><span class="sig-paren">(</span><em>arguments</em>, <em>keydict</em><span class="sig-paren">)</span><a class="headerlink" href="#aetools.keysubst" title="Permalink to this definition">¶</a></dt>
 
116
<dd><p>Converts a Python keyword argument dictionary <code class="docutils literal"><span class="pre">arguments</span></code> to the format
 
117
required by <code class="docutils literal"><span class="pre">packevent</span></code> by replacing the keys, which are Python identifiers,
 
118
by the four-character OSA keys according to the mapping specified in
 
119
<code class="docutils literal"><span class="pre">keydict</span></code>. Used by the generated suite packages.</p>
 
120
</dd></dl>
 
121
 
 
122
<dl class="function">
 
123
<dt id="aetools.enumsubst">
 
124
<code class="descclassname">aetools.</code><code class="descname">enumsubst</code><span class="sig-paren">(</span><em>arguments</em>, <em>key</em>, <em>edict</em><span class="sig-paren">)</span><a class="headerlink" href="#aetools.enumsubst" title="Permalink to this definition">¶</a></dt>
 
125
<dd><p>If the <code class="docutils literal"><span class="pre">arguments</span></code> dictionary contains an entry for <code class="docutils literal"><span class="pre">key</span></code> convert the value
 
126
for that entry according to dictionary <code class="docutils literal"><span class="pre">edict</span></code>. This converts human-readable
 
127
Python enumeration names to the OSA 4-character codes. Used by the generated
 
128
suite packages.</p>
 
129
</dd></dl>
 
130
 
 
131
<p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><code class="xref py py-mod docutils literal"><span class="pre">aetools</span></code></a> module defines the following class:</p>
 
132
<dl class="class">
 
133
<dt id="aetools.TalkTo">
 
134
<em class="property">class </em><code class="descclassname">aetools.</code><code class="descname">TalkTo</code><span class="sig-paren">(</span><span class="optional">[</span><em>signature=None</em>, <em>start=0</em>, <em>timeout=0</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#aetools.TalkTo" title="Permalink to this definition">¶</a></dt>
 
135
<dd><p>Base class for the proxy used to talk to an application. <code class="docutils literal"><span class="pre">signature</span></code> overrides
 
136
the class attribute <code class="docutils literal"><span class="pre">_signature</span></code> (which is usually set by subclasses) and is
 
137
the 4-char creator code defining the application to talk to. <code class="docutils literal"><span class="pre">start</span></code> can be
 
138
set to true to enable running the application on class instantiation.
 
139
<code class="docutils literal"><span class="pre">timeout</span></code> can be specified to change the default timeout used while waiting
 
140
for an AppleEvent reply.</p>
 
141
</dd></dl>
 
142
 
 
143
<dl class="method">
 
144
<dt id="aetools.TalkTo._start">
 
145
<code class="descclassname">TalkTo.</code><code class="descname">_start</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#aetools.TalkTo._start" title="Permalink to this definition">¶</a></dt>
 
146
<dd><p>Test whether the application is running, and attempt to start it if not.</p>
 
147
</dd></dl>
 
148
 
 
149
<dl class="method">
 
150
<dt id="aetools.TalkTo.send">
 
151
<code class="descclassname">TalkTo.</code><code class="descname">send</code><span class="sig-paren">(</span><em>code</em>, <em>subcode</em><span class="optional">[</span>, <em>parameters</em>, <em>attributes</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#aetools.TalkTo.send" title="Permalink to this definition">¶</a></dt>
 
152
<dd><p>Create the AppleEvent <code class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></code> for the verb with the OSA designation
 
153
<code class="docutils literal"><span class="pre">code,</span> <span class="pre">subcode</span></code> (which are the usual 4-character strings), pack the
 
154
<code class="docutils literal"><span class="pre">parameters</span></code> and <code class="docutils literal"><span class="pre">attributes</span></code> into it, send it to the target application,
 
155
wait for the reply, unpack the reply with <code class="docutils literal"><span class="pre">unpackevent</span></code> and return the reply
 
156
appleevent, the unpacked return values as a dictionary and the return
 
157
attributes.</p>
 
158
</dd></dl>
 
159
 
 
160
</div>
 
161
 
 
162
 
 
163
          </div>
 
164
        </div>
 
165
      </div>
 
166
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
167
        <div class="sphinxsidebarwrapper">
 
168
  <h4>Previous topic</h4>
 
169
  <p class="topless"><a href="gensuitemodule.html"
 
170
                        title="previous chapter">38.1. <code class="docutils literal"><span class="pre">gensuitemodule</span></code> &#8212; Generate OSA stub packages</a></p>
 
171
  <h4>Next topic</h4>
 
172
  <p class="topless"><a href="aepack.html"
 
173
                        title="next chapter">38.3. <code class="docutils literal"><span class="pre">aepack</span></code> &#8212; Conversion between Python variables and AppleEvent data containers</a></p>
 
174
<h3>This Page</h3>
 
175
<ul class="this-page-menu">
 
176
  <li><a href="../bugs.html">Report a Bug</a></li>
 
177
  <li><a href="../_sources/library/aetools.txt"
 
178
         rel="nofollow">Show Source</a></li>
 
179
</ul>
 
180
 
 
181
<div id="searchbox" style="display: none" role="search">
 
182
  <h3>Quick search</h3>
 
183
    <form class="search" action="../search.html" method="get">
 
184
      <input type="text" name="q" />
 
185
      <input type="submit" value="Go" />
 
186
      <input type="hidden" name="check_keywords" value="yes" />
 
187
      <input type="hidden" name="area" value="default" />
 
188
    </form>
 
189
    <p class="searchtip" style="font-size: 90%">
 
190
    Enter search terms or a module, class or function name.
 
191
    </p>
 
192
</div>
 
193
<script type="text/javascript">$('#searchbox').show(0);</script>
 
194
        </div>
 
195
      </div>
 
196
      <div class="clearer"></div>
 
197
    </div>  
 
198
    <div class="related" role="navigation" aria-label="related navigation">
 
199
      <h3>Navigation</h3>
 
200
      <ul>
 
201
        <li class="right" style="margin-right: 10px">
 
202
          <a href="../genindex.html" title="General Index"
 
203
             >index</a></li>
 
204
        <li class="right" >
 
205
          <a href="../py-modindex.html" title="Python Module Index"
 
206
             >modules</a> |</li>
 
207
        <li class="right" >
 
208
          <a href="aepack.html" title="38.3. aepack — Conversion between Python variables and AppleEvent data containers"
 
209
             >next</a> |</li>
 
210
        <li class="right" >
 
211
          <a href="gensuitemodule.html" title="38.1. gensuitemodule — Generate OSA stub packages"
 
212
             >previous</a> |</li>
 
213
        <li><img src="../_static/py.png" alt=""
 
214
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
215
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
216
        <li>
 
217
          <span class="version_switcher_placeholder">2.7.12</span>
 
218
          <a href="../index.html">Documentation</a> &raquo;
 
219
        </li>
 
220
 
 
221
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
 
222
          <li class="nav-item nav-item-2"><a href="macosa.html" >38. MacPython OSA Modules</a> &raquo;</li> 
 
223
      </ul>
 
224
    </div>  
 
225
    <div class="footer">
 
226
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
 
227
    <br />
 
228
    The Python Software Foundation is a non-profit corporation.
 
229
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
230
    <br />
 
231
    Last updated on Sep 20, 2016.
 
232
    <a href="../bugs.html">Found a bug</a>?
 
233
    <br />
 
234
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
235
    </div>
 
236
 
 
237
  </body>
 
238
</html>
 
 
b'\\ No newline at end of file'