[427fa87] | 1 | """ |
---|
| 2 | This module provide GUI for the neutron scattering length density calculator |
---|
| 3 | @author: Gervaise B. Alina |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | import wx |
---|
| 7 | import sys |
---|
| 8 | |
---|
| 9 | from sans.guiframe.utils import format_number, check_float |
---|
| 10 | from sans.guicomm.events import StatusEvent |
---|
| 11 | from sans.calculator.sld_calculator import SldCalculator |
---|
| 12 | |
---|
| 13 | _BOX_WIDTH = 76 |
---|
| 14 | _STATICBOX_WIDTH = 350 |
---|
| 15 | _SCALE = 1e-6 |
---|
| 16 | |
---|
| 17 | #SLD panel size |
---|
[39e49a1] | 18 | if sys.platform.count("win32")>0: |
---|
[427fa87] | 19 | _STATICBOX_WIDTH = 350 |
---|
| 20 | PANEL_SIZE = 400 |
---|
| 21 | FONT_VARIANT = 0 |
---|
| 22 | else: |
---|
| 23 | _STATICBOX_WIDTH = 380 |
---|
| 24 | PANEL_SIZE = 430 |
---|
| 25 | FONT_VARIANT = 1 |
---|
| 26 | |
---|
| 27 | class SldPanel(wx.Panel): |
---|
| 28 | """ |
---|
| 29 | Provides the SLD calculator GUI. |
---|
| 30 | """ |
---|
| 31 | ## Internal nickname for the window, used by the AUI manager |
---|
| 32 | window_name = "SLD Calculator" |
---|
| 33 | ## Name to appear on the window title bar |
---|
| 34 | window_caption = "SLD Calculator" |
---|
| 35 | ## Flag to tell the AUI manager to put this panel in the center pane |
---|
| 36 | CENTER_PANE = True |
---|
| 37 | def __init__(self, parent,base=None, id = -1): |
---|
| 38 | wx.Panel.__init__(self, parent, id = id) |
---|
| 39 | #Font size |
---|
| 40 | self.SetWindowVariant(variant=FONT_VARIANT) |
---|
| 41 | |
---|
| 42 | # Object that receive status event |
---|
[39e49a1] | 43 | self.base = base |
---|
[427fa87] | 44 | self.calculator = SldCalculator() |
---|
| 45 | self.wavelength = self.calculator.wavelength |
---|
| 46 | |
---|
| 47 | self._do_layout() |
---|
| 48 | self.SetAutoLayout(True) |
---|
| 49 | self.Layout() |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | def _do_layout(self): |
---|
| 53 | """ |
---|
| 54 | Draw window content |
---|
| 55 | """ |
---|
| 56 | unit_a = '[A]' |
---|
| 57 | unit_density = '[g/cm^(3)]' |
---|
[39e49a1] | 58 | unit_sld = '[1/A^(2)]' |
---|
| 59 | unit_cm1 ='[1/cm]' |
---|
| 60 | unit_cm ='[cm]' |
---|
[427fa87] | 61 | sizer_input = wx.GridBagSizer(5,5) |
---|
| 62 | sizer_output = wx.GridBagSizer(5,5) |
---|
| 63 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 64 | sizer1 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 65 | sizer2 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 66 | sizer3 = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 67 | #---------inputs---------------- |
---|
| 68 | inputbox = wx.StaticBox(self, -1, "Input") |
---|
| 69 | boxsizer1 = wx.StaticBoxSizer(inputbox, wx.VERTICAL) |
---|
| 70 | boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1)) |
---|
| 71 | |
---|
| 72 | compound_txt = wx.StaticText(self, -1, 'Compound ') |
---|
| 73 | self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 74 | density_txt = wx.StaticText(self, -1, 'Density ') |
---|
| 75 | self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 76 | unit_density_txt = wx.StaticText(self, -1, unit_density) |
---|
| 77 | wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') |
---|
| 78 | self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 79 | self.wavelength_ctl.SetValue(str(self.wavelength)) |
---|
| 80 | unit_a_txt = wx.StaticText(self, -1, unit_a) |
---|
| 81 | iy = 0 |
---|
| 82 | ix = 0 |
---|
| 83 | sizer_input.Add(compound_txt,(iy, ix),(1,1),\ |
---|
| 84 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 85 | ix +=1 |
---|
| 86 | sizer_input.Add(self.compound_ctl,(iy, ix),(1,1),\ |
---|
| 87 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 88 | iy += 1 |
---|
| 89 | ix = 0 |
---|
| 90 | sizer_input.Add(density_txt,(iy, ix),(1,1),\ |
---|
| 91 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[39e49a1] | 92 | ix += 1 |
---|
| 93 | sizer_input.Add(self.density_ctl, (iy, ix), (1,1),\ |
---|
[427fa87] | 94 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 95 | ix +=1 |
---|
| 96 | sizer_input.Add(unit_density_txt,(iy, ix),(1,1),\ |
---|
| 97 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 98 | iy += 1 |
---|
| 99 | ix = 0 |
---|
[39e49a1] | 100 | sizer_input.Add(wavelength_txt, (iy, ix),(1,1),\ |
---|
[427fa87] | 101 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[39e49a1] | 102 | ix += 1 |
---|
[427fa87] | 103 | sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\ |
---|
| 104 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 105 | ix += 1 |
---|
[427fa87] | 106 | sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\ |
---|
| 107 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 108 | boxsizer1.Add( sizer_input ) |
---|
| 109 | sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
| 110 | #---------Outputs sizer-------- |
---|
| 111 | outputbox = wx.StaticBox(self, -1, "Output") |
---|
| 112 | boxsizer2 = wx.StaticBoxSizer(outputbox, wx.VERTICAL) |
---|
| 113 | boxsizer2.SetMinSize((_STATICBOX_WIDTH,-1)) |
---|
| 114 | |
---|
[39e49a1] | 115 | i_complex = '+ i' |
---|
[427fa87] | 116 | neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') |
---|
| 117 | self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 118 | self.neutron_sld_reel_ctl.SetEditable(False) |
---|
[017ec0b7] | 119 | self.neutron_sld_reel_ctl.SetToolTipString("Neutron SLD real.") |
---|
[427fa87] | 120 | self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 121 | self.neutron_sld_im_ctl.SetEditable(False) |
---|
| 122 | self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.") |
---|
| 123 | neutron_sld_units_txt = wx.StaticText(self, -1, unit_sld) |
---|
| 124 | |
---|
| 125 | cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') |
---|
| 126 | self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 127 | self.cu_ka_sld_reel_ctl.SetEditable(False) |
---|
[017ec0b7] | 128 | self.cu_ka_sld_reel_ctl.SetToolTipString("Cu Ka SLD real.") |
---|
[427fa87] | 129 | self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 130 | self.cu_ka_sld_im_ctl.SetEditable(False) |
---|
| 131 | self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") |
---|
| 132 | cu_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) |
---|
| 133 | |
---|
| 134 | mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') |
---|
| 135 | self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 136 | self.mo_ka_sld_reel_ctl.SetEditable(False) |
---|
[017ec0b7] | 137 | self.mo_ka_sld_reel_ctl.SetToolTipString("Mo Ka SLD real.") |
---|
[427fa87] | 138 | self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 139 | self.mo_ka_sld_im_ctl.SetEditable(False) |
---|
[017ec0b7] | 140 | self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD imaginary.") |
---|
[427fa87] | 141 | mo_ka_sld_units_txt = wx.StaticText(self, -1, unit_sld) |
---|
| 142 | |
---|
| 143 | neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') |
---|
| 144 | self.neutron_inc_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 145 | self.neutron_inc_ctl.SetEditable(False) |
---|
| 146 | self.neutron_inc_ctl.SetToolTipString("Neutron Inc. Xs") |
---|
| 147 | neutron_inc_units_txt = wx.StaticText(self, -1, unit_cm1) |
---|
[25a2ee3] | 148 | |
---|
[90b23e1] | 149 | neutron_abs_txt = wx.StaticText(self, -1, 'Neutron Abs. Xs') |
---|
[427fa87] | 150 | self.neutron_abs_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 151 | self.neutron_abs_ctl.SetEditable(False) |
---|
| 152 | self.neutron_abs_ctl.SetToolTipString("Neutron Abs. Xs") |
---|
| 153 | neutron_abs_units_txt = wx.StaticText(self, -1, unit_cm1) |
---|
[25a2ee3] | 154 | |
---|
[427fa87] | 155 | neutron_length_txt = wx.StaticText(self, -1, 'Neutron 1/e length') |
---|
| 156 | self.neutron_length_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) |
---|
| 157 | self.neutron_length_ctl.SetEditable(False) |
---|
| 158 | self.neutron_length_ctl.SetToolTipString("Neutron 1/e length") |
---|
| 159 | neutron_length_units_txt = wx.StaticText(self, -1, unit_cm) |
---|
[25a2ee3] | 160 | |
---|
[427fa87] | 161 | iy = 0 |
---|
| 162 | ix = 0 |
---|
| 163 | sizer_output.Add(neutron_sld_txt,(iy, ix),(1,1), |
---|
| 164 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[39e49a1] | 165 | ix += 1 |
---|
[427fa87] | 166 | sizer_output.Add(self.neutron_sld_reel_ctl,(iy, ix),(1,1), |
---|
| 167 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 168 | ix += 1 |
---|
[427fa87] | 169 | sizer_output.Add(wx.StaticText(self, -1, i_complex) |
---|
| 170 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 171 | ix +=1 |
---|
| 172 | sizer_output.Add(self.neutron_sld_im_ctl |
---|
| 173 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 174 | ix +=1 |
---|
| 175 | sizer_output.Add(neutron_sld_units_txt |
---|
| 176 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 177 | iy += 1 |
---|
| 178 | ix = 0 |
---|
| 179 | sizer_output.Add(cu_ka_sld_txt,(iy, ix),(1,1), |
---|
| 180 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 181 | ix +=1 |
---|
| 182 | sizer_output.Add(self.cu_ka_sld_reel_ctl,(iy, ix),(1,1), |
---|
| 183 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 184 | ix +=1 |
---|
| 185 | sizer_output.Add(wx.StaticText(self, -1, i_complex) |
---|
| 186 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 187 | ix += 1 |
---|
[427fa87] | 188 | sizer_output.Add(self.cu_ka_sld_im_ctl |
---|
| 189 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 190 | ix += 1 |
---|
[427fa87] | 191 | sizer_output.Add(cu_ka_sld_units_txt |
---|
| 192 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 193 | iy += 1 |
---|
| 194 | ix = 0 |
---|
| 195 | sizer_output.Add(mo_ka_sld_txt,(iy, ix),(1,1), |
---|
| 196 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 197 | ix +=1 |
---|
| 198 | sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix),(1,1), |
---|
| 199 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 200 | ix +=1 |
---|
| 201 | sizer_output.Add(wx.StaticText(self, -1, i_complex) |
---|
| 202 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 203 | ix += 1 |
---|
[427fa87] | 204 | sizer_output.Add(self.mo_ka_sld_im_ctl |
---|
| 205 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 206 | ix +=1 |
---|
| 207 | sizer_output.Add(mo_ka_sld_units_txt |
---|
| 208 | ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 209 | iy += 1 |
---|
| 210 | ix = 0 |
---|
| 211 | sizer_output.Add(neutron_inc_txt,(iy, ix),(1,1), |
---|
| 212 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[39e49a1] | 213 | ix += 1 |
---|
[427fa87] | 214 | sizer_output.Add(self.neutron_inc_ctl,(iy, ix),(1,1), |
---|
| 215 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 216 | ix += 2 |
---|
[427fa87] | 217 | sizer_output.Add(neutron_inc_units_txt,(iy, ix),(1,1), |
---|
| 218 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 219 | iy += 1 |
---|
| 220 | ix = 0 |
---|
[39e49a1] | 221 | sizer_output.Add(neutron_abs_txt, (iy, ix), (1,1), |
---|
[427fa87] | 222 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[39e49a1] | 223 | ix += 1 |
---|
| 224 | sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1,1), |
---|
[427fa87] | 225 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 226 | ix +=2 |
---|
[39e49a1] | 227 | sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1,1), |
---|
[427fa87] | 228 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 229 | iy += 1 |
---|
| 230 | ix = 0 |
---|
[39e49a1] | 231 | sizer_output.Add(neutron_length_txt, (iy, ix), (1,1), |
---|
[427fa87] | 232 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 233 | ix +=1 |
---|
[39e49a1] | 234 | sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1,1), |
---|
[427fa87] | 235 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[39e49a1] | 236 | ix += 2 |
---|
| 237 | sizer_output.Add(neutron_length_units_txt, (iy, ix), (1,1), |
---|
[427fa87] | 238 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 239 | boxsizer2.Add( sizer_output ) |
---|
[39e49a1] | 240 | sizer2.Add(boxsizer2,0, wx.EXPAND|wx.ALL, 10) |
---|
[427fa87] | 241 | #-----Button sizer------------ |
---|
| 242 | |
---|
| 243 | id = wx.NewId() |
---|
| 244 | button_calculate = wx.Button(self, id, "Calculate") |
---|
[017ec0b7] | 245 | button_calculate.SetToolTipString("Calculate SLD.") |
---|
[427fa87] | 246 | self.Bind(wx.EVT_BUTTON, self.calculateSld, id = id) |
---|
| 247 | |
---|
| 248 | sizer_button.Add((250, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 249 | sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE,20) |
---|
| 250 | sizer3.Add(sizer_button) |
---|
| 251 | #---------layout---------------- |
---|
| 252 | vbox = wx.BoxSizer(wx.VERTICAL) |
---|
| 253 | vbox.Add(sizer1) |
---|
| 254 | vbox.Add(sizer2) |
---|
| 255 | vbox.Add(sizer3) |
---|
| 256 | vbox.Fit(self) |
---|
| 257 | self.SetSizer(vbox) |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | def check_inputs(self): |
---|
| 261 | """Check validity user inputs""" |
---|
[39e49a1] | 262 | flag = True |
---|
[427fa87] | 263 | |
---|
| 264 | if check_float(self.density_ctl): |
---|
| 265 | self.density = float(self.density_ctl.GetValue()) |
---|
| 266 | else: |
---|
[39e49a1] | 267 | flag = False |
---|
[427fa87] | 268 | raise ValueError,"Error for Density value :expect float" |
---|
| 269 | |
---|
[39e49a1] | 270 | self.wavelength = self.wavelength_ctl.GetValue() |
---|
| 271 | if self.wavelength.lstrip().rstrip() == "": |
---|
[427fa87] | 272 | self.wavelength = self.calculator.wavelength |
---|
| 273 | else: |
---|
| 274 | if check_float(self.wavelength_ctl): |
---|
[39e49a1] | 275 | self.wavelength = float(self.wavelength) |
---|
[427fa87] | 276 | else: |
---|
| 277 | flag = False |
---|
| 278 | raise ValueError,"Error for wavelenth value :expect float" |
---|
| 279 | |
---|
[39e49a1] | 280 | self.formulata_text = self.compound_ctl.GetValue().lstrip().rstrip() |
---|
| 281 | if self.formulata_text != "": |
---|
[427fa87] | 282 | self.compound_ctl.SetBackgroundColour(wx.WHITE) |
---|
| 283 | self.compound_ctl.Refresh() |
---|
| 284 | else: |
---|
| 285 | self.compound_ctl.SetBackgroundColour("pink") |
---|
| 286 | self.compound_ctl.Refresh() |
---|
[39e49a1] | 287 | flag = False |
---|
[427fa87] | 288 | raise ValueError, "Enter a formula" |
---|
| 289 | return flag |
---|
| 290 | |
---|
| 291 | def calculateSld(self, event): |
---|
| 292 | """ |
---|
| 293 | Calculate the neutron scattering density length of a molecule |
---|
| 294 | """ |
---|
| 295 | try: |
---|
| 296 | #Check validity user inputs |
---|
| 297 | if self.check_inputs(): |
---|
| 298 | #get ready to compute |
---|
| 299 | try: |
---|
[39e49a1] | 300 | self.calculator.set_value(self.formulata_text, |
---|
| 301 | self.density, self.wavelength) |
---|
[427fa87] | 302 | except: |
---|
[39e49a1] | 303 | if self.base is not None: |
---|
| 304 | msg = "SLD Calculator: %s" %(sys.exc_value) |
---|
| 305 | wx.PostEvent(self.base, StatusEvent(status=msg)) |
---|
[427fa87] | 306 | else: |
---|
| 307 | raise |
---|
| 308 | return |
---|
| 309 | |
---|
| 310 | # Compute the Cu SLD |
---|
[39e49a1] | 311 | Cu_reel, Cu_im = self.calculator.calculate_xray_sld( "Cu") |
---|
| 312 | self.cu_ka_sld_reel_ctl.SetValue(format_number(Cu_reel *_SCALE)) |
---|
| 313 | self.cu_ka_sld_im_ctl.SetValue(format_number(Cu_im * _SCALE)) |
---|
[427fa87] | 314 | |
---|
| 315 | # Compute the Mo SLD |
---|
[39e49a1] | 316 | Mo_reel, Mo_im = self.calculator.calculate_xray_sld( "Mo") |
---|
| 317 | self.mo_ka_sld_reel_ctl.SetValue(format_number(Mo_reel *_SCALE)) |
---|
| 318 | self.mo_ka_sld_im_ctl.SetValue(format_number(Mo_im * _SCALE)) |
---|
[427fa87] | 319 | |
---|
[25a2ee3] | 320 | sld_real, sld_im, inc = self.calculator.calculate_neutron_sld() |
---|
[39e49a1] | 321 | length = self.calculator.calculate_length() |
---|
[427fa87] | 322 | # Neutron SLD |
---|
[25a2ee3] | 323 | #need to be compute by element package |
---|
| 324 | absorp = 1.0 |
---|
| 325 | length = 1.0 |
---|
| 326 | self.neutron_sld_reel_ctl.SetValue(format_number(sld_real * _SCALE)) |
---|
| 327 | self.neutron_sld_im_ctl.SetValue(format_number(sld_im * _SCALE)) |
---|
[39e49a1] | 328 | self.neutron_inc_ctl.SetValue(format_number(inc)) |
---|
[427fa87] | 329 | self.neutron_abs_ctl.SetValue(format_number(absorp)) |
---|
| 330 | # Neutron length |
---|
| 331 | self.neutron_length_ctl.SetValue(format_number(length)) |
---|
| 332 | # display wavelength |
---|
| 333 | self.wavelength_ctl.SetValue(str(self.wavelength)) |
---|
| 334 | except: |
---|
[39e49a1] | 335 | if self.base is not None: |
---|
| 336 | msg = "SLD Calculator: %s"%(sys.exc_value) |
---|
| 337 | wx.PostEvent(self.base, StatusEvent(status=msg)) |
---|
[427fa87] | 338 | else: |
---|
| 339 | raise |
---|
| 340 | return |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | |
---|
| 346 | |
---|
| 347 | |
---|
| 348 | |
---|
| 349 | |
---|
| 350 | class SldWindow(wx.Frame): |
---|
| 351 | def __init__(self, parent=None, id=1, title="SLD Calculator",base=None): |
---|
| 352 | wx.Frame.__init__(self, parent, id, title, size=( PANEL_SIZE, PANEL_SIZE)) |
---|
| 353 | |
---|
| 354 | self.panel = SldPanel(self, base=base) |
---|
| 355 | self.Centre() |
---|
| 356 | self.Show(True) |
---|
| 357 | |
---|
| 358 | class ViewApp(wx.App): |
---|
| 359 | def OnInit(self): |
---|
| 360 | frame = SldWindow(None, -1, 'SLD Calculator') |
---|
| 361 | frame.Show(True) |
---|
| 362 | self.SetTopWindow(frame) |
---|
| 363 | |
---|
| 364 | return True |
---|
| 365 | |
---|
| 366 | |
---|
| 367 | if __name__ == "__main__": |
---|
| 368 | app = ViewApp(0) |
---|
| 369 | app.MainLoop() |
---|