source: pvMail/doc/build/html/_modules/PvMail/traits_gui.html @ 932

Last change on this file since 932 was 932, checked in by jemian, 10 years ago

moving to new address: xor --> xray

  • Property svn:mime-type set to text/html
File size: 21.1 KB
Line 
1
2
3<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6
7<html xmlns="http://www.w3.org/1999/xhtml">
8  <head>
9    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
10   
11    <title>PvMail.traits_gui &mdash; PvMail 3 (3.0-r801) documentation</title>
12   
13    <link rel="stylesheet" href="../../_static/sphinxdoc.css" type="text/css" />
14    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
15   
16    <script type="text/javascript">
17      var DOCUMENTATION_OPTIONS = {
18        URL_ROOT:    '../../',
19        VERSION:     '3 (3.0-r801)',
20        COLLAPSE_INDEX: false,
21        FILE_SUFFIX: '.html',
22        HAS_SOURCE:  true
23      };
24    </script>
25    <script type="text/javascript" src="../../_static/jquery.js"></script>
26    <script type="text/javascript" src="../../_static/underscore.js"></script>
27    <script type="text/javascript" src="../../_static/doctools.js"></script>
28    <link rel="top" title="PvMail 3 (3.0-r801) documentation" href="../../index.html" />
29    <link rel="up" title="Module code" href="../index.html" /> 
30  </head>
31  <body>
32    <div class="related">
33      <h3>Navigation</h3>
34      <ul>
35        <li class="right" style="margin-right: 10px">
36          <a href="../../genindex.html" title="General Index"
37             accesskey="I">index</a></li>
38        <li class="right" >
39          <a href="../../py-modindex.html" title="Python Module Index"
40             >modules</a> |</li>
41        <li><a href="../../index.html">PvMail 3 (3.0-r801) documentation</a> &raquo;</li>
42          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
43      </ul>
44    </div>
45      <div class="sphinxsidebar">
46        <div class="sphinxsidebarwrapper">
47<div id="searchbox" style="display: none">
48  <h3>Quick search</h3>
49    <form class="search" action="../../search.html" method="get">
50      <input type="text" name="q" />
51      <input type="submit" value="Go" />
52      <input type="hidden" name="check_keywords" value="yes" />
53      <input type="hidden" name="area" value="default" />
54    </form>
55    <p class="searchtip" style="font-size: 90%">
56    Enter search terms or a module, class or function name.
57    </p>
58</div>
59<script type="text/javascript">$('#searchbox').show(0);</script>
60        </div>
61      </div>
62
63    <div class="document">
64      <div class="documentwrapper">
65        <div class="bodywrapper">
66          <div class="body">
67           
68  <h1>Source code for PvMail.traits_gui</h1><div class="highlight"><pre>
69<span class="c">#!/usr/bin/env python</span>
70
71<span class="c">########### SVN repository information ###################</span>
72<span class="c"># $Date: 2012-04-12 17:38:59 -0500 (Thu, 12 Apr 2012) $</span>
73<span class="c"># $Author: jemian $</span>
74<span class="c"># $Revision: 801 $</span>
75<span class="c"># $URL: https://subversion.xray.aps.anl.gov/bcdaext/pvMail/src/PvMail/traits_gui.py $</span>
76<span class="c"># $Id: traits_gui.py 801 2012-04-12 22:38:59Z jemian $</span>
77<span class="c">########### SVN repository information ###################</span>
78
79<span class="sd">&#39;&#39;&#39;</span>
80<span class="sd">===================================</span>
81<span class="sd">pvMail: just the GUI</span>
82<span class="sd">===================================</span>
83
84<span class="sd">Build the Graphical User Interface for PvMail</span>
85<span class="sd">using the Traits library from the</span>
86<span class="sd">Enthought Python Distribution. </span>
87
88<span class="sd">Copyright (c) 2011, UChicago Argonne, LLC</span>
89<span class="sd">&#39;&#39;&#39;</span>
90
91
92<span class="kn">import</span> <span class="nn">pvMail</span>
93
94<span class="kn">from</span> <span class="nn">enthought.traits.api</span> <span class="kn">import</span> <span class="n">HasTraits</span><span class="p">,</span> <span class="n">String</span><span class="p">,</span> <span class="n">List</span><span class="p">,</span> <span class="n">Bool</span><span class="p">,</span> <span class="n">Generic</span>
95<span class="kn">from</span> <span class="nn">enthought.traits.ui.api</span> <span class="kn">import</span> <span class="n">Item</span><span class="p">,</span> <span class="n">View</span><span class="p">,</span> <span class="n">StatusItem</span><span class="p">,</span> <span class="n">Action</span><span class="p">,</span> <span class="n">Handler</span>
96
97
98<span class="n">__svnid__</span> <span class="o">=</span> <span class="s">&quot;$Id: traits_gui.py 801 2012-04-12 22:38:59Z jemian $&quot;</span>
99
100
101<div class="viewcode-block" id="ActionHandler"><a class="viewcode-back" href="../../pvMail/pvMail.html#PvMail.traits_gui.ActionHandler">[docs]</a><span class="k">class</span> <span class="nc">ActionHandler</span><span class="p">(</span><span class="n">Handler</span><span class="p">):</span>
102    <span class="sd">&#39;&#39;&#39;implements controls for PvMail GUI application&#39;&#39;&#39;</span>
103   
104    <span class="n">_gui</span> <span class="o">=</span> <span class="bp">None</span>
105   
106    <span class="k">def</span> <span class="nf">_findGui</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">uinfo</span><span class="p">):</span>
107        <span class="sd">&#39;&#39;&#39;return the PvMail_GUI object&#39;&#39;&#39;</span>
108        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
109            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span> <span class="o">=</span> <span class="n">uinfo</span><span class="o">.</span><span class="n">object</span>
110   
111<div class="viewcode-block" id="ActionHandler.do_run"><a class="viewcode-back" href="../../pvMail/pvMail.html#PvMail.traits_gui.ActionHandler.do_run">[docs]</a>    <span class="k">def</span> <span class="nf">do_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">uinfo</span><span class="p">):</span>
112        <span class="sd">&#39;&#39;&#39;</span>
113<span class="sd">        start watching the EPICS triggerPV</span>
114<span class="sd">        </span>
115<span class="sd">        :param obj uinfo: UIInfo object passed from the Action()</span>
116<span class="sd">        </span>
117<span class="sd">        Traits Handler method that responds to a Traits Action()</span>
118<span class="sd">        &#39;&#39;&#39;</span>
119        <span class="bp">self</span><span class="o">.</span><span class="n">_findGui</span><span class="p">(</span><span class="n">uinfo</span><span class="p">)</span>
120        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">running</span><span class="p">:</span>
121            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">SetStatus</span><span class="p">(</span><span class="s">&#39;&lt;Run&gt; button pressed&#39;</span><span class="p">)</span>
122            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">running</span> <span class="o">=</span> <span class="bp">True</span>
123            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span> <span class="o">=</span> <span class="n">pvMail</span><span class="o">.</span><span class="n">PvMail</span><span class="p">()</span>
124            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span><span class="o">.</span><span class="n">triggerPV</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">triggerPV</span>
125            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span><span class="o">.</span><span class="n">messagePV</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">messagePV</span>
126            <span class="n">addresses</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">recipients</span><span class="p">)</span>
127            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span><span class="o">.</span><span class="n">recipients</span> <span class="o">=</span> <span class="n">addresses</span>
128            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span><span class="o">.</span><span class="n">do_start</span><span class="p">()</span>
129        <span class="k">else</span><span class="p">:</span>
130            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">SetStatus</span><span class="p">(</span><span class="s">&#39;Already running&#39;</span><span class="p">)</span>
131    </div>
132<div class="viewcode-block" id="ActionHandler.do_stop"><a class="viewcode-back" href="../../pvMail/pvMail.html#PvMail.traits_gui.ActionHandler.do_stop">[docs]</a>    <span class="k">def</span> <span class="nf">do_stop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">uinfo</span><span class="p">):</span>
133        <span class="sd">&#39;&#39;&#39;</span>
134<span class="sd">        stop watching the EPICS triggerPV</span>
135<span class="sd">        </span>
136<span class="sd">        :param obj uinfo: UIInfo object passed from the Action()</span>
137<span class="sd">        </span>
138<span class="sd">        Traits Handler method that responds to a Traits Action()</span>
139<span class="sd">        &#39;&#39;&#39;</span>
140        <span class="bp">self</span><span class="o">.</span><span class="n">_findGui</span><span class="p">(</span><span class="n">uinfo</span><span class="p">)</span>
141        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">running</span><span class="p">:</span>
142            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">SetStatus</span><span class="p">(</span><span class="s">&#39;&lt;Stop&gt; button pressed&#39;</span><span class="p">)</span>
143            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">running</span> <span class="o">=</span> <span class="bp">False</span>
144            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span><span class="o">.</span><span class="n">do_stop</span><span class="p">()</span>
145            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">pvm</span> <span class="o">=</span> <span class="bp">None</span>
146        <span class="k">else</span><span class="p">:</span>
147            <span class="bp">self</span><span class="o">.</span><span class="n">_gui</span><span class="o">.</span><span class="n">SetStatus</span><span class="p">(</span><span class="s">&#39;Not running&#39;</span><span class="p">)</span>
148
149</div></div>
150<div class="viewcode-block" id="PvMail_GUI"><a class="viewcode-back" href="../../pvMail/pvMail.html#PvMail.traits_gui.PvMail_GUI">[docs]</a><span class="k">class</span> <span class="nc">PvMail_GUI</span><span class="p">(</span><span class="n">HasTraits</span><span class="p">):</span>
151    <span class="sd">&#39;&#39;&#39;</span>
152<span class="sd">    GUI used for pvMail,</span>
153<span class="sd">    declared using Enthought&#39;s Traits module</span>
154<span class="sd">    &#39;&#39;&#39;</span>
155    <span class="n">triggerPV</span> <span class="o">=</span> <span class="n">String</span><span class="p">(</span>
156                 <span class="n">desc</span><span class="o">=</span><span class="s">&quot;EPICS PV name on which to trigger an email&quot;</span><span class="p">,</span>
157                 <span class="n">label</span><span class="o">=</span><span class="s">&quot;trigger PV&quot;</span><span class="p">,)</span>
158    <span class="n">messagePV</span> <span class="o">=</span> <span class="n">String</span><span class="p">(</span>
159                 <span class="n">desc</span><span class="o">=</span><span class="s">&quot;EPICS string PV name with short message text&quot;</span><span class="p">,</span>
160                 <span class="n">label</span><span class="o">=</span><span class="s">&quot;message PV&quot;</span><span class="p">,)</span>
161    <span class="n">recipients</span> <span class="o">=</span> <span class="n">List</span><span class="p">(</span>
162                 <span class="n">trait</span><span class="o">=</span><span class="n">String</span><span class="p">,</span>
163                 <span class="n">value</span><span class="o">=</span><span class="p">[</span><span class="s">&quot;&quot;</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">,],</span>
164                 <span class="n">desc</span><span class="o">=</span><span class="s">&quot;email addresses of message recipients&quot;</span><span class="p">,</span>
165                 <span class="n">label</span><span class="o">=</span><span class="s">&quot;email address(es)&quot;</span><span class="p">,)</span>
166    <span class="n">actionRun</span> <span class="o">=</span> <span class="n">Action</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;Run&quot;</span><span class="p">,</span>
167                       <span class="n">desc</span> <span class="o">=</span> <span class="s">&quot;start watching for trigger PV to go from 0 to 1&quot;</span><span class="p">,</span>
168                       <span class="n">action</span> <span class="o">=</span> <span class="s">&quot;do_run&quot;</span><span class="p">)</span>
169    <span class="n">actionStop</span> <span class="o">=</span> <span class="n">Action</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&quot;Stop&quot;</span><span class="p">,</span>
170                        <span class="n">desc</span> <span class="o">=</span> <span class="s">&quot;stop watching trigger PV&quot;</span><span class="p">,</span>
171                        <span class="n">action</span> <span class="o">=</span> <span class="s">&quot;do_stop&quot;</span><span class="p">)</span>
172
173    <span class="n">status_label</span> <span class="o">=</span> <span class="n">String</span><span class="p">(</span><span class="s">&#39;status:&#39;</span><span class="p">)</span>
174    <span class="n">status_msg</span> <span class="o">=</span> <span class="n">String</span>
175    <span class="n">running</span> <span class="o">=</span> <span class="n">Bool</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span>
176    <span class="n">pvm</span> <span class="o">=</span> <span class="n">Generic</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>
177   
178    <span class="n">view</span> <span class="o">=</span> <span class="n">View</span><span class="p">(</span><span class="s">&#39;triggerPV&#39;</span><span class="p">,</span> 
179                <span class="s">&#39;messagePV&#39;</span><span class="p">,</span> 
180                <span class="s">&#39;recipients&#39;</span><span class="p">,</span> 
181                <span class="n">Item</span><span class="p">(</span><span class="s">&#39;running&#39;</span><span class="p">,</span> <span class="n">style</span> <span class="o">=</span> <span class="s">&#39;readonly&#39;</span><span class="p">,</span> <span class="n">label</span> <span class="o">=</span> <span class="s">&#39;Running?&#39;</span><span class="p">,</span> <span class="p">),</span>
182                <span class="n">title</span><span class="o">=</span><span class="s">&quot;PvMail GUI&quot;</span><span class="p">,</span>
183                <span class="n">width</span><span class="o">=</span><span class="mi">500</span><span class="p">,</span>
184                <span class="n">height</span><span class="o">=</span><span class="mi">300</span><span class="p">,</span>
185                <span class="n">buttons</span> <span class="o">=</span> <span class="p">[</span><span class="n">actionRun</span><span class="p">,</span> <span class="n">actionStop</span><span class="p">],</span>
186                <span class="n">handler</span> <span class="o">=</span> <span class="n">ActionHandler</span><span class="p">(),</span>
187                <span class="n">statusbar</span> <span class="o">=</span> <span class="p">[</span>
188                   <span class="n">StatusItem</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#39;status_label&#39;</span><span class="p">,</span> <span class="n">width</span> <span class="o">=</span> <span class="mi">80</span><span class="p">),</span>
189                   <span class="n">StatusItem</span><span class="p">(</span><span class="n">name</span> <span class="o">=</span> <span class="s">&#39;status_msg&#39;</span><span class="p">,</span> <span class="n">width</span> <span class="o">=</span> <span class="mf">0.5</span><span class="p">),</span>
190                <span class="p">],</span>
191                <span class="n">resizable</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
192
193    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> 
194                 <span class="n">triggerPV</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="p">,</span> 
195                 <span class="n">messagePV</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="p">,</span> 
196                 <span class="n">recipients</span> <span class="o">=</span> <span class="p">[</span><span class="s">&quot;&quot;</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">],</span> 
197                 <span class="n">log_file</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="p">,</span>
198                 <span class="o">**</span><span class="n">kwtraits</span><span class="p">):</span>
199        <span class="sd">&#39;&#39;&#39;make this class callable from pvMail application&#39;&#39;&#39;</span>
200        <span class="nb">super</span><span class="p">(</span><span class="n">PvMail_GUI</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwtraits</span><span class="p">)</span>
201        <span class="bp">self</span><span class="o">.</span><span class="n">triggerPV</span> <span class="o">=</span> <span class="n">triggerPV</span>
202        <span class="bp">self</span><span class="o">.</span><span class="n">messagePV</span> <span class="o">=</span> <span class="n">messagePV</span>
203        <span class="bp">self</span><span class="o">.</span><span class="n">recipients</span> <span class="o">=</span> <span class="n">recipients</span>
204        <span class="bp">self</span><span class="o">.</span><span class="n">SetStatus</span><span class="p">(</span><span class="s">&#39;log file = &#39;</span> <span class="o">+</span> <span class="n">log_file</span><span class="p">)</span>
205
206<div class="viewcode-block" id="PvMail_GUI.SetStatus"><a class="viewcode-back" href="../../pvMail/pvMail.html#PvMail.traits_gui.PvMail_GUI.SetStatus">[docs]</a>    <span class="k">def</span> <span class="nf">SetStatus</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">msg</span><span class="p">):</span>
207        <span class="sd">&#39;&#39;&#39;put text in the status box&#39;&#39;&#39;</span>
208        <span class="bp">self</span><span class="o">.</span><span class="n">status_msg</span> <span class="o">=</span> <span class="n">msg</span>
209
210</div></div>
211<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
212    <span class="k">print</span> <span class="s">&quot;Do not call this module directly.  Use pvMail.py instead&quot;</span>
213</pre></div>
214
215          </div>
216        </div>
217      </div>
218      <div class="clearer"></div>
219    </div>
220    <div class="related">
221      <h3>Navigation</h3>
222      <ul>
223        <li class="right" style="margin-right: 10px">
224          <a href="../../genindex.html" title="General Index"
225             >index</a></li>
226        <li class="right" >
227          <a href="../../py-modindex.html" title="Python Module Index"
228             >modules</a> |</li>
229        <li><a href="../../index.html">PvMail 3 (3.0-r801) documentation</a> &raquo;</li>
230          <li><a href="../index.html" >Module code</a> &raquo;</li> 
231      </ul>
232    </div>
233    <div class="footer">
234        &copy; Copyright (c) 2009-2012, UChicago Argonne, LLC (see LICENSE file for details).
235      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
236    </div>
237  </body>
238</html>
Note: See TracBrowser for help on using the repository browser.