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>sas.perspectives.calculator.density_panel — SasView 3.0.0 documentation</title> |
---|
10 | |
---|
11 | <link rel="stylesheet" href="../../../../_static/default.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: '3.0.0', |
---|
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="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
---|
27 | <link rel="top" title="SasView 3.0.0 documentation" href="../../../../index.html" /> |
---|
28 | <link rel="up" title="sas.perspectives.calculator" href="../calculator.html" /> |
---|
29 | </head> |
---|
30 | <body> |
---|
31 | <div class="related"> |
---|
32 | <h3>Navigation</h3> |
---|
33 | <ul> |
---|
34 | <li class="right" style="margin-right: 10px"> |
---|
35 | <a href="../../../../genindex.html" title="General Index" |
---|
36 | accesskey="I">index</a></li> |
---|
37 | <li class="right" > |
---|
38 | <a href="../../../../py-modindex.html" title="Python Module Index" |
---|
39 | >modules</a> |</li> |
---|
40 | <li><a href="../../../../index.html">SasView 3.0.0 documentation</a> »</li> |
---|
41 | <li><a href="../../../index.html" >Module code</a> »</li> |
---|
42 | <li><a href="../calculator.html" accesskey="U">sas.perspectives.calculator</a> »</li> |
---|
43 | </ul> |
---|
44 | </div> |
---|
45 | |
---|
46 | <div class="document"> |
---|
47 | <div class="documentwrapper"> |
---|
48 | <div class="bodywrapper"> |
---|
49 | <div class="body"> |
---|
50 | |
---|
51 | <h1>Source code for sas.perspectives.calculator.density_panel</h1><div class="highlight"><pre> |
---|
52 | <span class="sd">"""</span> |
---|
53 | <span class="sd">This module provide GUI for the mass density calculator</span> |
---|
54 | |
---|
55 | <span class="sd">"""</span> |
---|
56 | <span class="kn">import</span> <span class="nn">wx</span> |
---|
57 | <span class="kn">import</span> <span class="nn">sys</span> |
---|
58 | <span class="kn">from</span> <span class="nn">sas.guiframe.panel_base</span> <span class="kn">import</span> <span class="n">PanelBase</span> |
---|
59 | <span class="kn">from</span> <span class="nn">wx.lib.scrolledpanel</span> <span class="kn">import</span> <span class="n">ScrolledPanel</span> |
---|
60 | <span class="kn">from</span> <span class="nn">sas.guiframe.utils</span> <span class="kn">import</span> <span class="n">check_float</span> |
---|
61 | <span class="kn">from</span> <span class="nn">sas.guiframe.events</span> <span class="kn">import</span> <span class="n">StatusEvent</span> |
---|
62 | <span class="kn">from</span> <span class="nn">periodictable</span> <span class="kn">import</span> <span class="n">formula</span> <span class="k">as</span> <span class="n">Formula</span> |
---|
63 | <span class="kn">from</span> <span class="nn">sas.perspectives.calculator</span> <span class="kn">import</span> <span class="n">calculator_widgets</span> <span class="k">as</span> <span class="n">widget</span> |
---|
64 | |
---|
65 | <span class="n">AVOGADRO</span> <span class="o">=</span> <span class="mf">6.02214129e23</span> |
---|
66 | <span class="n">_INPUTS</span> <span class="o">=</span> <span class="p">[</span><span class="s">'Mass Density'</span><span class="p">,</span> <span class="s">'Molar Volume'</span><span class="p">]</span> |
---|
67 | <span class="n">_UNITS</span> <span class="o">=</span> <span class="p">[</span><span class="s">'g/cm^(3) '</span><span class="p">,</span> <span class="s">'cm^(3)/mol '</span><span class="p">]</span> |
---|
68 | <span class="c">#Density panel size </span> |
---|
69 | <span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">platform</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="s">"win32"</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> |
---|
70 | <span class="n">_STATICBOX_WIDTH</span> <span class="o">=</span> <span class="mi">410</span> |
---|
71 | <span class="n">_BOX_WIDTH</span> <span class="o">=</span> <span class="mi">200</span> |
---|
72 | <span class="n">PANEL_SIZE</span> <span class="o">=</span> <span class="mi">440</span> |
---|
73 | <span class="n">FONT_VARIANT</span> <span class="o">=</span> <span class="mi">0</span> |
---|
74 | <span class="k">else</span><span class="p">:</span> |
---|
75 | <span class="n">_STATICBOX_WIDTH</span> <span class="o">=</span> <span class="mi">430</span> |
---|
76 | <span class="n">_BOX_WIDTH</span> <span class="o">=</span> <span class="mi">200</span> |
---|
77 | <span class="n">PANEL_SIZE</span> <span class="o">=</span> <span class="mi">460</span> |
---|
78 | <span class="n">FONT_VARIANT</span> <span class="o">=</span> <span class="mi">1</span> |
---|
79 | |
---|
80 | <div class="viewcode-block" id="DensityPanel"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel">[docs]</a><span class="k">class</span> <span class="nc">DensityPanel</span><span class="p">(</span><span class="n">ScrolledPanel</span><span class="p">,</span> <span class="n">PanelBase</span><span class="p">):</span> |
---|
81 | <span class="sd">"""</span> |
---|
82 | <span class="sd"> Provides the mass density calculator GUI.</span> |
---|
83 | <span class="sd"> """</span> |
---|
84 | <span class="c">## Internal nickname for the window, used by the AUI manager</span> |
---|
85 | <span class="n">window_name</span> <span class="o">=</span> <span class="s">"Mass Density Calculator"</span> |
---|
86 | <span class="c">## Name to appear on the window title bar</span> |
---|
87 | <span class="n">window_caption</span> <span class="o">=</span> <span class="s">"Mass Density Calculator"</span> |
---|
88 | <span class="c">## Flag to tell the AUI manager to put this panel in the center pane</span> |
---|
89 | <span class="n">CENTER_PANE</span> <span class="o">=</span> <span class="bp">True</span> |
---|
90 | |
---|
91 | <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">):</span> |
---|
92 | <span class="sd">"""</span> |
---|
93 | <span class="sd"> """</span> |
---|
94 | <span class="n">ScrolledPanel</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">)</span> |
---|
95 | <span class="n">PanelBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> |
---|
96 | <span class="bp">self</span><span class="o">.</span><span class="n">SetupScrolling</span><span class="p">()</span> |
---|
97 | <span class="c">#Font size </span> |
---|
98 | <span class="bp">self</span><span class="o">.</span><span class="n">SetWindowVariant</span><span class="p">(</span><span class="n">variant</span><span class="o">=</span><span class="n">FONT_VARIANT</span><span class="p">)</span> |
---|
99 | <span class="c"># Object that receive status event</span> |
---|
100 | <span class="bp">self</span><span class="o">.</span><span class="n">base</span> <span class="o">=</span> <span class="n">base</span> |
---|
101 | <span class="c"># chemeical formula, string</span> |
---|
102 | <span class="bp">self</span><span class="o">.</span><span class="n">compound</span> <span class="o">=</span> <span class="s">''</span> |
---|
103 | <span class="c"># value of the density/volume, float</span> |
---|
104 | <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="bp">None</span> |
---|
105 | <span class="c"># text controls</span> |
---|
106 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span> <span class="o">=</span> <span class="bp">None</span> |
---|
107 | <span class="bp">self</span><span class="o">.</span><span class="n">input_ctl</span> <span class="o">=</span> <span class="bp">None</span> |
---|
108 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span> <span class="o">=</span> <span class="bp">None</span> |
---|
109 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span> <span class="o">=</span> <span class="bp">None</span> |
---|
110 | <span class="bp">self</span><span class="o">.</span><span class="n">ctr_color</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">GetBackgroundColour</span><span class="p">()</span> |
---|
111 | <span class="c"># button</span> |
---|
112 | <span class="bp">self</span><span class="o">.</span><span class="n">button_calculate</span> <span class="o">=</span> <span class="bp">None</span> |
---|
113 | <span class="c"># list</span> |
---|
114 | <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span> <span class="o">=</span> <span class="n">_INPUTS</span> |
---|
115 | <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> |
---|
116 | <span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> |
---|
117 | <span class="bp">self</span><span class="o">.</span><span class="n">_unit_list</span> <span class="o">=</span> <span class="n">_UNITS</span> |
---|
118 | <span class="c">#Draw the panel</span> |
---|
119 | <span class="bp">self</span><span class="o">.</span><span class="n">_do_layout</span><span class="p">()</span> |
---|
120 | <span class="bp">self</span><span class="o">.</span><span class="n">SetAutoLayout</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
121 | <span class="bp">self</span><span class="o">.</span><span class="n">Layout</span><span class="p">()</span> |
---|
122 | |
---|
123 | <span class="k">def</span> <span class="nf">_do_layout</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
124 | <span class="sd">"""</span> |
---|
125 | <span class="sd"> Draw window content</span> |
---|
126 | <span class="sd"> """</span> |
---|
127 | <span class="c"># units</span> |
---|
128 | <span class="n">unit_density</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unit_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> |
---|
129 | <span class="n">unit_volume</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_unit_list</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> |
---|
130 | |
---|
131 | <span class="c"># sizers</span> |
---|
132 | <span class="n">sizer_input</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">GridBagSizer</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> |
---|
133 | <span class="n">sizer_output</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">GridBagSizer</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span> <span class="mi">5</span><span class="p">)</span> |
---|
134 | <span class="n">sizer_button</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span> |
---|
135 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer1</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span> |
---|
136 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer2</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span> |
---|
137 | <span class="n">sizer3</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">HORIZONTAL</span><span class="p">)</span> |
---|
138 | <span class="n">vbox</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">BoxSizer</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span> |
---|
139 | |
---|
140 | <span class="c"># inputs</span> |
---|
141 | <span class="n">inputbox</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticBox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">"Inputs"</span><span class="p">)</span> |
---|
142 | <span class="n">boxsizer1</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticBoxSizer</span><span class="p">(</span><span class="n">inputbox</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span> |
---|
143 | <span class="n">boxsizer1</span><span class="o">.</span><span class="n">SetMinSize</span><span class="p">((</span><span class="n">_STATICBOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
144 | <span class="n">compound_txt</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">'Molecular Formula '</span><span class="p">)</span> |
---|
145 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">_BOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
146 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg1</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">' e.g., H2O'</span><span class="p">)</span> |
---|
147 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg2</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">'e.g., D2O'</span><span class="p">)</span> |
---|
148 | <span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="p">)</span> |
---|
149 | <span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_select_input</span><span class="p">)</span> |
---|
150 | <span class="n">hint_input_name_txt</span> <span class="o">=</span> <span class="s">'Mass or volume.'</span> |
---|
151 | <span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="o">.</span><span class="n">SetToolTipString</span><span class="p">(</span><span class="n">hint_input_name_txt</span><span class="p">)</span> |
---|
152 | <span class="n">unit_density1</span> <span class="o">=</span> <span class="s">" "</span> <span class="o">+</span> <span class="n">unit_density</span> |
---|
153 | <span class="bp">self</span><span class="o">.</span><span class="n">input_ctl</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">_BOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
154 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_density</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">unit_density1</span><span class="p">)</span> |
---|
155 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_volume</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">unit_volume</span><span class="p">)</span> |
---|
156 | <span class="n">iy</span> <span class="o">=</span> <span class="mi">0</span> |
---|
157 | <span class="n">ix</span> <span class="o">=</span> <span class="mi">0</span> |
---|
158 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">compound_txt</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
159 | <span class="n">wx</span><span class="o">.</span><span class="n">LEFT</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span> |
---|
160 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
161 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
162 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
163 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
164 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">compound_eg1</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
165 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
166 | |
---|
167 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
168 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">compound_eg2</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
169 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
170 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
171 | <span class="n">iy</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
172 | <span class="n">ix</span> <span class="o">=</span> <span class="mi">0</span> |
---|
173 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
174 | <span class="n">wx</span><span class="o">.</span><span class="n">LEFT</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span> |
---|
175 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
176 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_ctl</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
177 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
178 | <span class="n">ix</span> <span class="o">+=</span><span class="mi">1</span> |
---|
179 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unit_input_density</span><span class="p">,(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
180 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
181 | <span class="n">ix</span> <span class="o">+=</span><span class="mi">1</span> |
---|
182 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_density</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
183 | <span class="n">sizer_input</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unit_input_volume</span><span class="p">,(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
184 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
185 | <span class="n">boxsizer1</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">sizer_input</span><span class="p">)</span> |
---|
186 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer1</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">boxsizer1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span> <span class="o">|</span> <span class="n">wx</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> |
---|
187 | |
---|
188 | <span class="c"># outputs</span> |
---|
189 | <span class="n">outputbox</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticBox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">"Outputs"</span><span class="p">)</span> |
---|
190 | <span class="n">boxsizer2</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticBoxSizer</span><span class="p">(</span><span class="n">outputbox</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">VERTICAL</span><span class="p">)</span> |
---|
191 | <span class="n">boxsizer2</span><span class="o">.</span><span class="n">SetMinSize</span><span class="p">((</span><span class="n">_STATICBOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
192 | |
---|
193 | <span class="n">molar_mass_txt</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">'Molar Mass '</span><span class="p">)</span> |
---|
194 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">_BOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
195 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span><span class="o">.</span><span class="n">SetEditable</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
196 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ctr_color</span><span class="p">)</span> |
---|
197 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit1</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">' g/mol'</span><span class="p">)</span> |
---|
198 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit2</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="s">'g/mol'</span><span class="p">)</span> |
---|
199 | |
---|
200 | <span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">ComboBox</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">wx</span><span class="o">.</span><span class="n">CB_READONLY</span><span class="p">)</span> |
---|
201 | <span class="n">wx</span><span class="o">.</span><span class="n">EVT_COMBOBOX</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_select_output</span><span class="p">)</span> |
---|
202 | <span class="n">hint_output_name_txt</span> <span class="o">=</span> <span class="s">'Mass or volume.'</span> |
---|
203 | <span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="o">.</span><span class="n">SetToolTipString</span><span class="p">(</span><span class="n">hint_output_name_txt</span><span class="p">)</span> |
---|
204 | <span class="nb">list</span> <span class="o">=</span> <span class="p">[]</span> |
---|
205 | <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="p">:</span> |
---|
206 | <span class="n">name</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> |
---|
207 | <span class="nb">list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> |
---|
208 | <span class="nb">list</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span> |
---|
209 | <span class="k">for</span> <span class="n">idx</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="nb">list</span><span class="p">)):</span> |
---|
210 | <span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="o">.</span><span class="n">Append</span><span class="p">(</span><span class="nb">list</span><span class="p">[</span><span class="n">idx</span><span class="p">],</span><span class="n">idx</span><span class="p">)</span> |
---|
211 | <span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="o">.</span><span class="n">Append</span><span class="p">(</span><span class="nb">list</span><span class="p">[</span><span class="n">idx</span><span class="p">],</span><span class="n">idx</span><span class="p">)</span> |
---|
212 | <span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="o">.</span><span class="n">SetStringSelection</span><span class="p">(</span><span class="s">"Molar Volume"</span><span class="p">)</span> |
---|
213 | <span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="o">.</span><span class="n">SetStringSelection</span><span class="p">(</span><span class="s">"Mass Density"</span><span class="p">)</span> |
---|
214 | <span class="n">unit_volume</span> <span class="o">=</span> <span class="s">" "</span> <span class="o">+</span> <span class="n">unit_volume</span> |
---|
215 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">TextCtrl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">_BOX_WIDTH</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">))</span> |
---|
216 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span><span class="o">.</span><span class="n">SetEditable</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
217 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ctr_color</span><span class="p">)</span> |
---|
218 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_density</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">unit_density</span><span class="p">)</span> |
---|
219 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_volume</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">StaticText</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">unit_volume</span><span class="p">)</span> |
---|
220 | <span class="n">iy</span> <span class="o">=</span> <span class="mi">0</span> |
---|
221 | <span class="n">ix</span> <span class="o">=</span> <span class="mi">0</span> |
---|
222 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">molar_mass_txt</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
223 | <span class="n">wx</span><span class="o">.</span><span class="n">LEFT</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span> |
---|
224 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
225 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
226 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
227 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
228 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit1</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
229 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
230 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
231 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit2</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
232 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
233 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
234 | <span class="n">iy</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
235 | <span class="n">ix</span> <span class="o">=</span> <span class="mi">0</span> |
---|
236 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
237 | <span class="n">wx</span><span class="o">.</span><span class="n">LEFT</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">15</span><span class="p">)</span> |
---|
238 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
239 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span><span class="p">,</span> <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> |
---|
240 | <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
241 | <span class="n">ix</span> <span class="o">+=</span><span class="mi">1</span> |
---|
242 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unit_output_volume</span><span class="p">,</span> |
---|
243 | <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
244 | <span class="n">ix</span> <span class="o">+=</span> <span class="mi">1</span> |
---|
245 | <span class="n">sizer_output</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">unit_output_density</span><span class="p">,</span> |
---|
246 | <span class="p">(</span><span class="n">iy</span><span class="p">,</span> <span class="n">ix</span><span class="p">),</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
247 | |
---|
248 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_volume</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
249 | <span class="n">boxsizer2</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">sizer_output</span><span class="p">)</span> |
---|
250 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer2</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">boxsizer2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span> |
---|
251 | |
---|
252 | <span class="c"># buttons</span> |
---|
253 | <span class="nb">id</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">NewId</span><span class="p">()</span> |
---|
254 | <span class="bp">self</span><span class="o">.</span><span class="n">button_calculate</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">id</span><span class="p">,</span> <span class="s">"Calculate"</span><span class="p">)</span> |
---|
255 | <span class="bp">self</span><span class="o">.</span><span class="n">button_calculate</span><span class="o">.</span><span class="n">SetToolTipString</span><span class="p">(</span><span class="s">"Calculate."</span><span class="p">)</span> |
---|
256 | <span class="bp">self</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_BUTTON</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">calculate</span><span class="p">,</span> <span class="nb">id</span><span class="o">=</span><span class="nb">id</span><span class="p">)</span> |
---|
257 | |
---|
258 | <span class="n">sizer_button</span><span class="o">.</span><span class="n">Add</span><span class="p">((</span><span class="mi">250</span><span class="p">,</span> <span class="mi">20</span><span class="p">),</span> <span class="mi">1</span><span class="p">,</span> <span class="n">wx</span><span class="o">.</span><span class="n">EXPAND</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> |
---|
259 | <span class="n">sizer_button</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">button_calculate</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> |
---|
260 | <span class="n">wx</span><span class="o">.</span><span class="n">RIGHT</span><span class="o">|</span><span class="n">wx</span><span class="o">.</span><span class="n">ADJUST_MINSIZE</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span> |
---|
261 | <span class="n">sizer3</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">sizer_button</span><span class="p">)</span> |
---|
262 | |
---|
263 | <span class="c"># layout</span> |
---|
264 | <span class="n">vbox</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sizer1</span><span class="p">)</span> |
---|
265 | <span class="n">vbox</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sizer2</span><span class="p">)</span> |
---|
266 | <span class="n">vbox</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="n">sizer3</span><span class="p">)</span> |
---|
267 | <span class="n">vbox</span><span class="o">.</span><span class="n">Fit</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> |
---|
268 | <span class="bp">self</span><span class="o">.</span><span class="n">SetSizer</span><span class="p">(</span><span class="n">vbox</span><span class="p">)</span> |
---|
269 | |
---|
270 | <div class="viewcode-block" id="DensityPanel.on_select_input"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.on_select_input">[docs]</a> <span class="k">def</span> <span class="nf">on_select_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span> |
---|
271 | <span class="sd">"""</span> |
---|
272 | <span class="sd"> On selection of input combobox, </span> |
---|
273 | <span class="sd"> update units and output combobox</span> |
---|
274 | <span class="sd"> """</span> |
---|
275 | <span class="k">if</span> <span class="n">event</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span> |
---|
276 | <span class="k">return</span> |
---|
277 | <span class="n">event</span><span class="o">.</span><span class="n">Skip</span><span class="p">()</span> |
---|
278 | |
---|
279 | <span class="n">combo</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span> |
---|
280 | <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">=</span> <span class="n">combo</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span> |
---|
281 | <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="p">:</span> |
---|
282 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">!=</span> <span class="n">name</span><span class="p">:</span> |
---|
283 | <span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">name</span> |
---|
284 | <span class="k">break</span> |
---|
285 | |
---|
286 | <span class="bp">self</span><span class="o">.</span><span class="n">set_values</span><span class="p">()</span> |
---|
287 | </div> |
---|
288 | <div class="viewcode-block" id="DensityPanel.on_select_output"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.on_select_output">[docs]</a> <span class="k">def</span> <span class="nf">on_select_output</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span> |
---|
289 | <span class="sd">"""</span> |
---|
290 | <span class="sd"> On selection of output combobox, </span> |
---|
291 | <span class="sd"> update units and input combobox</span> |
---|
292 | <span class="sd"> """</span> |
---|
293 | <span class="k">if</span> <span class="n">event</span> <span class="o">==</span> <span class="bp">None</span><span class="p">:</span> |
---|
294 | <span class="k">return</span> |
---|
295 | <span class="n">event</span><span class="o">.</span><span class="n">Skip</span><span class="p">()</span> |
---|
296 | |
---|
297 | <span class="n">combo</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">GetEventObject</span><span class="p">()</span> |
---|
298 | <span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">combo</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span> |
---|
299 | <span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="p">:</span> |
---|
300 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">!=</span> <span class="n">name</span><span class="p">:</span> |
---|
301 | <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">=</span> <span class="n">name</span> |
---|
302 | <span class="k">break</span> |
---|
303 | |
---|
304 | <span class="bp">self</span><span class="o">.</span><span class="n">set_values</span><span class="p">()</span> |
---|
305 | </div> |
---|
306 | <div class="viewcode-block" id="DensityPanel.set_values"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.set_values">[docs]</a> <span class="k">def</span> <span class="nf">set_values</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
307 | <span class="sd">"""</span> |
---|
308 | <span class="sd"> Sets units and combobox values</span> |
---|
309 | <span class="sd"> """</span> |
---|
310 | <span class="nb">input</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_input</span><span class="p">()</span> |
---|
311 | <span class="k">if</span> <span class="nb">input</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> |
---|
312 | <span class="k">return</span> |
---|
313 | <span class="c"># input</span> |
---|
314 | <span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">input</span><span class="p">))</span> |
---|
315 | <span class="c"># output</span> |
---|
316 | <span class="bp">self</span><span class="o">.</span><span class="n">output_cb</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output</span><span class="p">))</span> |
---|
317 | <span class="c"># unit</span> |
---|
318 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input_list</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="nb">input</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span> |
---|
319 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
320 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit2</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
321 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
322 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg2</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
323 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_density</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
324 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_volume</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
325 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_volume</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
326 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_density</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
327 | <span class="k">else</span><span class="p">:</span> |
---|
328 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
329 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_unit2</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
330 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg1</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
331 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_eg2</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
332 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_volume</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
333 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_density</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
334 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_input_density</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
335 | <span class="bp">self</span><span class="o">.</span><span class="n">unit_output_volume</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">False</span><span class="p">)</span> |
---|
336 | <span class="c"># layout </span> |
---|
337 | <span class="bp">self</span><span class="o">.</span><span class="n">clear_outputs</span><span class="p">()</span> |
---|
338 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer1</span><span class="o">.</span><span class="n">Layout</span><span class="p">()</span> |
---|
339 | <span class="bp">self</span><span class="o">.</span><span class="n">sizer2</span><span class="o">.</span><span class="n">Layout</span><span class="p">()</span> |
---|
340 | </div> |
---|
341 | <div class="viewcode-block" id="DensityPanel.get_input"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.get_input">[docs]</a> <span class="k">def</span> <span class="nf">get_input</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
342 | <span class="sd">"""</span> |
---|
343 | <span class="sd"> Return the current input and output combobox values</span> |
---|
344 | <span class="sd"> """</span> |
---|
345 | <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_output</span> |
---|
346 | </div> |
---|
347 | <div class="viewcode-block" id="DensityPanel.check_inputs"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.check_inputs">[docs]</a> <span class="k">def</span> <span class="nf">check_inputs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
348 | <span class="sd">"""</span> |
---|
349 | <span class="sd"> Check validity user inputs</span> |
---|
350 | <span class="sd"> """</span> |
---|
351 | <span class="n">flag</span> <span class="o">=</span> <span class="bp">True</span> |
---|
352 | <span class="n">msg</span> <span class="o">=</span> <span class="s">""</span> |
---|
353 | <span class="k">if</span> <span class="n">check_float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_ctl</span><span class="p">):</span> |
---|
354 | <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_ctl</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span> |
---|
355 | <span class="k">else</span><span class="p">:</span> |
---|
356 | <span class="n">flag</span> <span class="o">=</span> <span class="bp">False</span> |
---|
357 | <span class="n">input_type</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input_cb</span><span class="o">.</span><span class="n">GetValue</span><span class="p">())</span> |
---|
358 | <span class="n">msg</span> <span class="o">+=</span> <span class="s">"Error for </span><span class="si">%s</span><span class="s"> value :expect float"</span><span class="o">%</span> <span class="n">input_type</span> |
---|
359 | |
---|
360 | <span class="bp">self</span><span class="o">.</span><span class="n">compound</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">GetValue</span><span class="p">()</span><span class="o">.</span><span class="n">lstrip</span><span class="p">()</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span> |
---|
361 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">compound</span> <span class="o">!=</span> <span class="s">""</span><span class="p">:</span> |
---|
362 | <span class="k">try</span> <span class="p">:</span> |
---|
363 | <span class="n">Formula</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">compound</span><span class="p">)</span> |
---|
364 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">WHITE</span><span class="p">)</span> |
---|
365 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">Refresh</span><span class="p">()</span> |
---|
366 | <span class="k">except</span><span class="p">:</span> |
---|
367 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="s">"pink"</span><span class="p">)</span> |
---|
368 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">Refresh</span><span class="p">()</span> |
---|
369 | <span class="n">flag</span> <span class="o">=</span> <span class="bp">False</span> |
---|
370 | <span class="n">msg</span> <span class="o">+=</span> <span class="s">"Enter correct formula"</span> |
---|
371 | <span class="k">else</span><span class="p">:</span> |
---|
372 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">SetBackgroundColour</span><span class="p">(</span><span class="s">"pink"</span><span class="p">)</span> |
---|
373 | <span class="bp">self</span><span class="o">.</span><span class="n">compound_ctl</span><span class="o">.</span><span class="n">Refresh</span><span class="p">()</span> |
---|
374 | <span class="n">flag</span> <span class="o">=</span> <span class="bp">False</span> |
---|
375 | <span class="n">msg</span> <span class="o">+=</span> <span class="s">"Enter Formula"</span> |
---|
376 | <span class="k">return</span> <span class="n">flag</span><span class="p">,</span> <span class="n">msg</span> |
---|
377 | |
---|
378 | </div> |
---|
379 | <div class="viewcode-block" id="DensityPanel.calculate"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.calculate">[docs]</a> <span class="k">def</span> <span class="nf">calculate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span> |
---|
380 | <span class="sd">"""</span> |
---|
381 | <span class="sd"> Calculate the mass Density/molar Volume of the molecules</span> |
---|
382 | <span class="sd"> """</span> |
---|
383 | <span class="bp">self</span><span class="o">.</span><span class="n">clear_outputs</span><span class="p">()</span> |
---|
384 | <span class="k">try</span><span class="p">:</span> |
---|
385 | <span class="c">#Check validity user inputs</span> |
---|
386 | <span class="n">flag</span><span class="p">,</span> <span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">check_inputs</span><span class="p">()</span> |
---|
387 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">base</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">msg</span><span class="o">.</span><span class="n">lstrip</span><span class="p">()</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span> <span class="o">!=</span> <span class="s">""</span><span class="p">:</span> |
---|
388 | <span class="n">msg</span> <span class="o">=</span> <span class="s">"Density/Volume Calculator: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span> |
---|
389 | <span class="n">wx</span><span class="o">.</span><span class="n">PostEvent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">base</span><span class="p">,</span> <span class="n">StatusEvent</span><span class="p">(</span><span class="n">status</span><span class="o">=</span><span class="n">msg</span><span class="p">))</span> |
---|
390 | <span class="k">if</span> <span class="ow">not</span> <span class="n">flag</span><span class="p">:</span> |
---|
391 | <span class="k">return</span> |
---|
392 | <span class="c">#get ready to compute</span> |
---|
393 | <span class="n">mol_formula</span> <span class="o">=</span> <span class="n">Formula</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">compound</span><span class="p">)</span> |
---|
394 | <span class="n">molar_mass</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">mol_formula</span><span class="o">.</span><span class="n">molecular_mass</span><span class="p">)</span> <span class="o">*</span> <span class="n">AVOGADRO</span> |
---|
395 | <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_number</span><span class="p">(</span><span class="n">molar_mass</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span><span class="p">)</span> |
---|
396 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_format_number</span><span class="p">(</span><span class="n">molar_mass</span><span class="p">)))</span> |
---|
397 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">output</span><span class="p">))</span> |
---|
398 | <span class="k">except</span><span class="p">:</span> |
---|
399 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">base</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> |
---|
400 | <span class="n">msg</span> <span class="o">=</span> <span class="s">"Density/Volume Calculator: </span><span class="si">%s</span><span class="s">"</span><span class="o">%</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">exc_value</span><span class="p">)</span> |
---|
401 | <span class="n">wx</span><span class="o">.</span><span class="n">PostEvent</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">base</span><span class="p">,</span> <span class="n">StatusEvent</span><span class="p">(</span><span class="n">status</span><span class="o">=</span><span class="n">msg</span><span class="p">))</span> |
---|
402 | <span class="k">if</span> <span class="n">event</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> |
---|
403 | <span class="n">event</span><span class="o">.</span><span class="n">Skip</span><span class="p">()</span> |
---|
404 | </div> |
---|
405 | <div class="viewcode-block" id="DensityPanel.clear_outputs"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityPanel.clear_outputs">[docs]</a> <span class="k">def</span> <span class="nf">clear_outputs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
406 | <span class="sd">"""</span> |
---|
407 | <span class="sd"> Clear the outputs textctrl</span> |
---|
408 | <span class="sd"> """</span> |
---|
409 | <span class="bp">self</span><span class="o">.</span><span class="n">molar_mass_ctl</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">""</span><span class="p">)</span> |
---|
410 | <span class="bp">self</span><span class="o">.</span><span class="n">output_ctl</span><span class="o">.</span><span class="n">SetValue</span><span class="p">(</span><span class="s">""</span><span class="p">)</span> |
---|
411 | </div> |
---|
412 | <span class="k">def</span> <span class="nf">_format_number</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> |
---|
413 | <span class="sd">"""</span> |
---|
414 | <span class="sd"> Return a float in a standardized, human-readable formatted string </span> |
---|
415 | <span class="sd"> """</span> |
---|
416 | <span class="k">try</span><span class="p">:</span> |
---|
417 | <span class="n">value</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> |
---|
418 | <span class="k">except</span><span class="p">:</span> |
---|
419 | <span class="n">output</span> <span class="o">=</span> <span class="s">''</span> |
---|
420 | <span class="k">return</span> <span class="n">output</span> |
---|
421 | |
---|
422 | <span class="n">output</span> <span class="o">=</span> <span class="s">"</span><span class="si">%-12.5f</span><span class="s">"</span> <span class="o">%</span> <span class="n">value</span> |
---|
423 | <span class="k">return</span> <span class="n">output</span><span class="o">.</span><span class="n">lstrip</span><span class="p">()</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span> |
---|
424 | </div> |
---|
425 | <div class="viewcode-block" id="DensityWindow"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityWindow">[docs]</a><span class="k">class</span> <span class="nc">DensityWindow</span><span class="p">(</span><span class="n">widget</span><span class="o">.</span><span class="n">CHILD_FRAME</span><span class="p">):</span> |
---|
426 | <span class="sd">"""</span> |
---|
427 | <span class="sd"> """</span> |
---|
428 | <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s">"Density/Volume Calculator"</span><span class="p">,</span> |
---|
429 | <span class="n">base</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">manager</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> |
---|
430 | <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="n">PANEL_SIZE</span><span class="p">,</span> <span class="n">PANEL_SIZE</span><span class="o">/</span><span class="mf">1.7</span><span class="p">),</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">):</span> |
---|
431 | <span class="sd">"""</span> |
---|
432 | <span class="sd"> """</span> |
---|
433 | <span class="n">kwds</span><span class="p">[</span><span class="s">'title'</span><span class="p">]</span> <span class="o">=</span> <span class="n">title</span> |
---|
434 | <span class="n">kwds</span><span class="p">[</span><span class="s">'size'</span><span class="p">]</span> <span class="o">=</span> <span class="n">size</span> |
---|
435 | <span class="n">widget</span><span class="o">.</span><span class="n">CHILD_FRAME</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwds</span><span class="p">)</span> |
---|
436 | <span class="sd">"""</span> |
---|
437 | <span class="sd"> """</span> |
---|
438 | <span class="bp">self</span><span class="o">.</span><span class="n">manager</span> <span class="o">=</span> <span class="n">manager</span> |
---|
439 | <span class="bp">self</span><span class="o">.</span><span class="n">panel</span> <span class="o">=</span> <span class="n">DensityPanel</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">base</span><span class="o">=</span><span class="n">base</span><span class="p">)</span> |
---|
440 | <span class="bp">self</span><span class="o">.</span><span class="n">Bind</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">EVT_CLOSE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">on_close</span><span class="p">)</span> |
---|
441 | <span class="bp">self</span><span class="o">.</span><span class="n">SetPosition</span><span class="p">((</span><span class="mi">25</span><span class="p">,</span> <span class="mi">160</span><span class="p">))</span> |
---|
442 | <span class="bp">self</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
443 | |
---|
444 | <div class="viewcode-block" id="DensityWindow.on_close"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.DensityWindow.on_close">[docs]</a> <span class="k">def</span> <span class="nf">on_close</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span> |
---|
445 | <span class="sd">"""</span> |
---|
446 | <span class="sd"> On close event</span> |
---|
447 | <span class="sd"> """</span> |
---|
448 | <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">manager</span> <span class="o">!=</span> <span class="bp">None</span><span class="p">:</span> |
---|
449 | <span class="bp">self</span><span class="o">.</span><span class="n">manager</span><span class="o">.</span><span class="n">cal_md_frame</span> <span class="o">=</span> <span class="bp">None</span> |
---|
450 | <span class="bp">self</span><span class="o">.</span><span class="n">Destroy</span><span class="p">()</span> |
---|
451 | |
---|
452 | </div></div> |
---|
453 | <div class="viewcode-block" id="ViewApp"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.ViewApp">[docs]</a><span class="k">class</span> <span class="nc">ViewApp</span><span class="p">(</span><span class="n">wx</span><span class="o">.</span><span class="n">App</span><span class="p">):</span> |
---|
454 | <span class="sd">"""</span> |
---|
455 | <span class="sd"> """</span> |
---|
456 | <div class="viewcode-block" id="ViewApp.OnInit"><a class="viewcode-back" href="../../../../dev/api/sas.perspectives.calculator.html#sas.perspectives.calculator.density_panel.ViewApp.OnInit">[docs]</a> <span class="k">def</span> <span class="nf">OnInit</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> |
---|
457 | <span class="sd">"""</span> |
---|
458 | <span class="sd"> """</span> |
---|
459 | <span class="n">widget</span><span class="o">.</span><span class="n">CHILD_FRAME</span> <span class="o">=</span> <span class="n">wx</span><span class="o">.</span><span class="n">Frame</span> |
---|
460 | <span class="n">frame</span> <span class="o">=</span> <span class="n">DensityWindow</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="s">"Density/Volume Calculator"</span><span class="p">)</span> |
---|
461 | <span class="n">frame</span><span class="o">.</span><span class="n">Show</span><span class="p">(</span><span class="bp">True</span><span class="p">)</span> |
---|
462 | <span class="bp">self</span><span class="o">.</span><span class="n">SetTopWindow</span><span class="p">(</span><span class="n">frame</span><span class="p">)</span> |
---|
463 | <span class="k">return</span> <span class="bp">True</span> |
---|
464 | |
---|
465 | </div></div> |
---|
466 | <span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">"__main__"</span><span class="p">:</span> |
---|
467 | <span class="n">app</span> <span class="o">=</span> <span class="n">ViewApp</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> |
---|
468 | <span class="n">app</span><span class="o">.</span><span class="n">MainLoop</span><span class="p">()</span> |
---|
469 | </pre></div> |
---|
470 | |
---|
471 | </div> |
---|
472 | </div> |
---|
473 | </div> |
---|
474 | <div class="sphinxsidebar"> |
---|
475 | <div class="sphinxsidebarwrapper"> |
---|
476 | <div id="searchbox" style="display: none"> |
---|
477 | <h3>Quick search</h3> |
---|
478 | <form class="search" action="../../../../search.html" method="get"> |
---|
479 | <input type="text" name="q" /> |
---|
480 | <input type="submit" value="Go" /> |
---|
481 | <input type="hidden" name="check_keywords" value="yes" /> |
---|
482 | <input type="hidden" name="area" value="default" /> |
---|
483 | </form> |
---|
484 | <p class="searchtip" style="font-size: 90%"> |
---|
485 | Enter search terms or a module, class or function name. |
---|
486 | </p> |
---|
487 | </div> |
---|
488 | <script type="text/javascript">$('#searchbox').show(0);</script> |
---|
489 | </div> |
---|
490 | </div> |
---|
491 | <div class="clearer"></div> |
---|
492 | </div> |
---|
493 | <div class="related"> |
---|
494 | <h3>Navigation</h3> |
---|
495 | <ul> |
---|
496 | <li class="right" style="margin-right: 10px"> |
---|
497 | <a href="../../../../genindex.html" title="General Index" |
---|
498 | >index</a></li> |
---|
499 | <li class="right" > |
---|
500 | <a href="../../../../py-modindex.html" title="Python Module Index" |
---|
501 | >modules</a> |</li> |
---|
502 | <li><a href="../../../../index.html">SasView 3.0.0 documentation</a> »</li> |
---|
503 | <li><a href="../../../index.html" >Module code</a> »</li> |
---|
504 | <li><a href="../calculator.html" >sas.perspectives.calculator</a> »</li> |
---|
505 | </ul> |
---|
506 | </div> |
---|
507 | <div class="footer"> |
---|
508 | © Copyright 2013, The SasView Project. |
---|
509 | Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. |
---|
510 | </div> |
---|
511 | </body> |
---|
512 | </html> |
---|