Changeset b0ab6cb in sasview for calculatorview/perspectives/calculator/sld_panel.py
- Timestamp:
- Oct 27, 2010 2:41:30 PM (14 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 6cda91f
- Parents:
- c4d6900
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
calculatorview/perspectives/calculator/sld_panel.py
r855546d rb0ab6cb 1 1 """ 2 3 @author: Gervaise B. Alina 2 This module provide GUI for the neutron scattering length density calculator 3 4 4 """ 5 5 … … 8 8 import sys 9 9 10 from sans.guiframe.utils import format_number, check_float 10 from sans.guiframe.utils import format_number 11 from sans.guiframe.utils import check_float 11 12 from sans.guicomm.events import StatusEvent 12 13 13 14 # the calculator default value for wavelength is 6 14 import periodictable15 #import periodictable 15 16 from periodictable import formula 16 from periodictable.xsf import xray_energy, xray_sld_from_atoms 17 from periodictable.constants import avogadro_number 18 from periodictable.nsf import neutron_scattering 17 from periodictable.xsf import xray_energy 18 from periodictable.xsf import xray_sld_from_atoms 19 #rom periodictable.constants import avogadro_number 20 from periodictable.nsf import neutron_scattering 19 21 20 22 WAVELENGTH = 6.0 … … 24 26 25 27 #SLD panel size 26 if sys.platform.count("win32") >0:28 if sys.platform.count("win32") > 0: 27 29 _STATICBOX_WIDTH = 350 28 30 PANEL_SIZE = 400 … … 35 37 class SldPanel(wx.Panel): 36 38 """ 37 39 Provides the SLD calculator GUI. 38 40 """ 39 41 ## Internal nickname for the window, used by the AUI manager … … 43 45 ## Flag to tell the AUI manager to put this panel in the center pane 44 46 CENTER_PANE = True 45 def __init__(self, parent, base=None, id=-1): 46 wx.Panel.__init__(self, parent, id = id) 47 48 def __init__(self, parent, base=None): 49 """ 50 """ 51 wx.Panel.__init__(self, parent) 47 52 #Font size 48 53 self.SetWindowVariant(variant=FONT_VARIANT) … … 50 55 self.base = base 51 56 self.wavelength = WAVELENGTH 57 #layout attribute 58 self.compound_ctl = None 59 self.density_ctl = None 60 self.wavelength_ctl = None 61 self.neutron_sld_reel_ctl = None 62 self.neutron_sld_im_ctl = None 63 self.mo_ka_sld_reel_ctl = None 64 self.mo_ka_sld_im_ctl = None 65 self.cu_ka_sld_reel_ctl = None 66 self.cu_ka_sld_im_ctl = None 67 self.neutron_abs_ctl = None 68 self.neutron_inc_ctl = None 69 self.neutron_length_ctl = None 52 70 #Draw the panel 53 71 self._do_layout() … … 57 75 def _do_layout(self): 58 76 """ 59 77 Draw window content 60 78 """ 61 79 unit_a = '[A]' 62 80 unit_density = '[g/cm^(3)]' 63 81 unit_sld = '[1/A^(2)]' 64 unit_cm1 = '[1/cm]'65 unit_cm = '[cm]'66 sizer_input = wx.GridBagSizer(5, 5)67 sizer_output = wx.GridBagSizer(5, 5)82 unit_cm1 = '[1/cm]' 83 unit_cm = '[cm]' 84 sizer_input = wx.GridBagSizer(5, 5) 85 sizer_output = wx.GridBagSizer(5, 5) 68 86 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 69 87 sizer1 = wx.BoxSizer(wx.HORIZONTAL) … … 73 91 inputbox = wx.StaticBox(self, -1, "Input") 74 92 boxsizer1 = wx.StaticBoxSizer(inputbox, wx.VERTICAL) 75 boxsizer1.SetMinSize((_STATICBOX_WIDTH, -1))93 boxsizer1.SetMinSize((_STATICBOX_WIDTH, -1)) 76 94 77 95 compound_txt = wx.StaticText(self, -1, 'Compound ') 78 self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1))96 self.compound_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 79 97 density_txt = wx.StaticText(self, -1, 'Density ') 80 self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1))98 self.density_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 81 99 unit_density_txt = wx.StaticText(self, -1, unit_density) 82 100 wavelength_txt = wx.StaticText(self, -1, 'Wavelength ') 83 self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1))101 self.wavelength_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH, -1)) 84 102 self.wavelength_ctl.SetValue(str(self.wavelength)) 85 103 unit_a_txt = wx.StaticText(self, -1, unit_a) 86 104 iy = 0 87 105 ix = 0 88 sizer_input.Add(compound_txt,(iy, ix),(1,1),\ 89 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 106 sizer_input.Add(compound_txt, (iy, ix), (1, 1), 107 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 108 ix += 1 109 sizer_input.Add(self.compound_ctl, (iy, ix), (1, 1), 110 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 111 iy += 1 112 ix = 0 113 sizer_input.Add(density_txt, (iy, ix), (1, 1), 114 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 115 ix += 1 116 sizer_input.Add(self.density_ctl, (iy, ix), (1, 1), 117 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 90 118 ix +=1 91 sizer_input.Add(self.compound_ctl,(iy, ix),(1,1),\ 92 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 93 iy += 1 94 ix = 0 95 sizer_input.Add(density_txt,(iy, ix),(1,1),\ 96 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 97 ix += 1 98 sizer_input.Add(self.density_ctl, (iy, ix), (1,1),\ 99 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 100 ix +=1 101 sizer_input.Add(unit_density_txt,(iy, ix),(1,1),\ 102 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 103 iy += 1 104 ix = 0 105 sizer_input.Add(wavelength_txt, (iy, ix),(1,1),\ 106 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 107 ix += 1 108 sizer_input.Add(self.wavelength_ctl,(iy, ix),(1,1),\ 109 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 110 ix += 1 111 sizer_input.Add(unit_a_txt,(iy, ix),(1,1),\ 112 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 113 boxsizer1.Add( sizer_input ) 114 sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 119 sizer_input.Add(unit_density_txt,(iy, ix), (1, 1), 120 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 121 iy += 1 122 ix = 0 123 sizer_input.Add(wavelength_txt, (iy, ix), (1, 1), 124 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 125 ix += 1 126 sizer_input.Add(self.wavelength_ctl, (iy, ix), (1, 1), 127 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 128 ix += 1 129 sizer_input.Add(unit_a_txt, (iy, ix), (1, 1), 130 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 131 boxsizer1.Add(sizer_input) 132 sizer1.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 115 133 #---------Outputs sizer-------- 116 134 outputbox = wx.StaticBox(self, -1, "Output") 117 135 boxsizer2 = wx.StaticBoxSizer(outputbox, wx.VERTICAL) 118 boxsizer2.SetMinSize((_STATICBOX_WIDTH, -1))136 boxsizer2.SetMinSize((_STATICBOX_WIDTH, -1)) 119 137 120 138 i_complex = '- i' 121 139 neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') 122 self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 140 self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, 141 size=(_BOX_WIDTH, -1)) 123 142 self.neutron_sld_reel_ctl.SetEditable(False) 124 143 self.neutron_sld_reel_ctl.SetToolTipString("Neutron SLD real.") 125 self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 144 self.neutron_sld_im_ctl = wx.TextCtrl(self, -1, 145 size=(_BOX_WIDTH, -1)) 126 146 self.neutron_sld_im_ctl.SetEditable(False) 127 147 self.neutron_sld_im_ctl.SetToolTipString("Neutron SLD imaginary.") … … 129 149 130 150 cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') 131 self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 151 self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 152 size=(_BOX_WIDTH, -1)) 132 153 self.cu_ka_sld_reel_ctl.SetEditable(False) 133 154 self.cu_ka_sld_reel_ctl.SetToolTipString("Cu Ka SLD real.") 134 self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 155 self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1, 156 size=(_BOX_WIDTH, -1)) 135 157 self.cu_ka_sld_im_ctl.SetEditable(False) 136 158 self.cu_ka_sld_im_ctl.SetToolTipString("Cu Ka SLD imaginary.") … … 138 160 139 161 mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') 140 self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 162 self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 163 size=(_BOX_WIDTH, -1)) 141 164 self.mo_ka_sld_reel_ctl.SetEditable(False) 142 165 self.mo_ka_sld_reel_ctl.SetToolTipString("Mo Ka SLD real.") 143 self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 166 self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, 167 size=(_BOX_WIDTH, -1)) 144 168 self.mo_ka_sld_im_ctl.SetEditable(False) 145 169 self.mo_ka_sld_im_ctl.SetToolTipString("Mo Ka SLD imaginary.") … … 147 171 148 172 neutron_inc_txt = wx.StaticText(self, -1, 'Neutron Inc. Xs') 149 self.neutron_inc_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 173 self.neutron_inc_ctl = wx.TextCtrl(self, -1, 174 size=(_BOX_WIDTH, -1)) 150 175 self.neutron_inc_ctl.SetEditable(False) 151 176 self.neutron_inc_ctl.SetToolTipString("Neutron Inc. Xs") … … 153 178 154 179 neutron_abs_txt = wx.StaticText(self, -1, 'Neutron Abs. Xs') 155 self.neutron_abs_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 180 self.neutron_abs_ctl = wx.TextCtrl(self, -1, 181 size=(_BOX_WIDTH, -1)) 156 182 self.neutron_abs_ctl.SetEditable(False) 157 183 self.neutron_abs_ctl.SetToolTipString("Neutron Abs. Xs") … … 159 185 160 186 neutron_length_txt = wx.StaticText(self, -1, 'Neutron 1/e length') 161 self.neutron_length_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 187 self.neutron_length_ctl = wx.TextCtrl(self, -1, 188 size=(_BOX_WIDTH, -1)) 162 189 self.neutron_length_ctl.SetEditable(False) 163 190 self.neutron_length_ctl.SetToolTipString("Neutron 1/e length") … … 166 193 iy = 0 167 194 ix = 0 168 sizer_output.Add(neutron_sld_txt, (iy, ix),(1,1),169 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 170 ix += 1 171 sizer_output.Add(self.neutron_sld_reel_ctl, (iy, ix),(1,1),172 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 173 ix += 1 174 sizer_output.Add(wx.StaticText(self, -1, i_complex) 175 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)176 ix += 1177 sizer_output.Add(self.neutron_sld_im_ctl 178 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)179 ix += 1180 sizer_output.Add(neutron_sld_units_txt 181 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)182 iy += 1 183 ix = 0 184 sizer_output.Add(cu_ka_sld_txt, (iy, ix),(1,1),185 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 186 ix += 1187 sizer_output.Add(self.cu_ka_sld_reel_ctl, (iy, ix),(1,1),188 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 189 ix += 1190 sizer_output.Add(wx.StaticText(self, -1, i_complex) 191 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)192 ix += 1 193 sizer_output.Add(self.cu_ka_sld_im_ctl 194 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)195 ix += 1 196 sizer_output.Add(cu_ka_sld_units_txt 197 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)198 iy += 1 199 ix = 0 200 sizer_output.Add(mo_ka_sld_txt,(iy, ix), (1,1),201 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 202 ix += 1203 sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix), (1,1),204 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 205 ix += 1206 sizer_output.Add(wx.StaticText(self, -1, i_complex) 207 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)208 ix += 1 209 sizer_output.Add(self.mo_ka_sld_im_ctl 210 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)211 ix += 1212 sizer_output.Add(mo_ka_sld_units_txt 213 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)214 iy += 1 215 ix = 0 216 sizer_output.Add(neutron_inc_txt, (iy, ix),(1,1),217 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 218 ix += 1 219 sizer_output.Add(self.neutron_inc_ctl, (iy, ix),(1,1),195 sizer_output.Add(neutron_sld_txt, (iy, ix), (1, 1), 196 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 197 ix += 1 198 sizer_output.Add(self.neutron_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) 203 ix += 1 204 sizer_output.Add(self.neutron_sld_im_ctl, 205 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 206 ix += 1 207 sizer_output.Add(neutron_sld_units_txt, 208 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 209 iy += 1 210 ix = 0 211 sizer_output.Add(cu_ka_sld_txt, (iy, ix), (1, 1), 212 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 213 ix += 1 214 sizer_output.Add(self.cu_ka_sld_reel_ctl, (iy, ix), (1, 1), 215 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 216 ix += 1 217 sizer_output.Add(wx.StaticText(self, -1, i_complex), 218 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 219 ix += 1 220 sizer_output.Add(self.cu_ka_sld_im_ctl, 221 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 222 ix += 1 223 sizer_output.Add(cu_ka_sld_units_txt, 224 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 225 iy += 1 226 ix = 0 227 sizer_output.Add(mo_ka_sld_txt,(iy, ix), (1, 1), 228 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 229 ix += 1 230 sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix), (1, 1), 231 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 232 ix += 1 233 sizer_output.Add(wx.StaticText(self, -1, i_complex), 234 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 235 ix += 1 236 sizer_output.Add(self.mo_ka_sld_im_ctl, 237 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 238 ix += 1 239 sizer_output.Add(mo_ka_sld_units_txt, 240 (iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 241 iy += 1 242 ix = 0 243 sizer_output.Add(neutron_inc_txt, (iy, ix), (1, 1), 244 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 245 ix += 1 246 sizer_output.Add(self.neutron_inc_ctl, (iy, ix), (1, 1), 220 247 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 221 248 ix += 2 222 sizer_output.Add(neutron_inc_units_txt,(iy, ix), (1,1),223 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 224 iy += 1 225 ix = 0 226 sizer_output.Add(neutron_abs_txt, (iy, ix), (1, 1),227 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 228 ix += 1 229 sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1, 1),230 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 231 ix += 2232 sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1, 1),233 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 234 iy += 1 235 ix = 0 236 sizer_output.Add(neutron_length_txt, (iy, ix), (1, 1),237 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 238 ix += 1239 sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1, 1),249 sizer_output.Add(neutron_inc_units_txt,(iy, ix), (1, 1), 250 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 251 iy += 1 252 ix = 0 253 sizer_output.Add(neutron_abs_txt, (iy, ix), (1, 1), 254 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 255 ix += 1 256 sizer_output.Add(self.neutron_abs_ctl, (iy, ix), (1, 1), 257 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 258 ix += 2 259 sizer_output.Add(neutron_abs_units_txt, (iy, ix), (1, 1), 260 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 261 iy += 1 262 ix = 0 263 sizer_output.Add(neutron_length_txt, (iy, ix), (1, 1), 264 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 265 ix += 1 266 sizer_output.Add(self.neutron_length_ctl, (iy, ix), (1, 1), 240 267 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 241 268 ix += 2 242 sizer_output.Add(neutron_length_units_txt, (iy, ix), (1, 1),269 sizer_output.Add(neutron_length_units_txt, (iy, ix), (1, 1), 243 270 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 244 boxsizer2.Add( sizer_output)245 sizer2.Add(boxsizer2, 0, wx.EXPAND|wx.ALL, 10)271 boxsizer2.Add(sizer_output) 272 sizer2.Add(boxsizer2, 0, wx.EXPAND|wx.ALL, 10) 246 273 #-----Button sizer------------ 247 274 … … 249 276 button_calculate = wx.Button(self, id, "Calculate") 250 277 button_calculate.SetToolTipString("Calculate SLD.") 251 self.Bind(wx.EVT_BUTTON, self.calculateSld, id =id)278 self.Bind(wx.EVT_BUTTON, self.calculateSld, id=id) 252 279 253 280 sizer_button.Add((250, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 254 sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20)281 sizer_button.Add(button_calculate, 0, wx.RIGHT|wx.ADJUST_MINSIZE, 20) 255 282 sizer3.Add(sizer_button) 256 283 #---------layout---------------- … … 297 324 else: 298 325 flag = False 299 raise ValueError, "Error for wavelength value :expect float"326 raise ValueError, "Error for wavelength value :expect float" 300 327 301 328 self.compound = self.compound_ctl.GetValue().lstrip().rstrip() … … 335 362 #get ready to compute 336 363 try: 337 self.sld_formula = formula(self.compound, density=self.density) 364 self.sld_formula = formula(self.compound, 365 density=self.density) 338 366 except: 339 367 if self.base is not None: 340 msg = "SLD Calculator: %s" %(sys.exc_value)368 msg = "SLD Calculator: %s" % (sys.exc_value) 341 369 wx.PostEvent(self.base, StatusEvent(status=msg)) 342 370 else: … … 345 373 346 374 347 (sld_real, sld_im, sld_inc), (coh,absorp,incoh), \375 (sld_real, sld_im, _), (_, absorp, incoh), \ 348 376 length = neutron_scattering(self.compound, 349 377 self.density, self.wavelength) … … 355 383 molecule_formula=self.sld_formula) 356 384 # set neutron sld values 357 self.neutron_sld_reel_ctl.SetValue(format_number(sld_real * _SCALE)) 358 self.neutron_sld_im_ctl.SetValue(format_number(math.fabs(sld_im) * _SCALE)) 385 val = format_number(sld_real * _SCALE) 386 self.neutron_sld_reel_ctl.SetValue(val) 387 val = format_number(math.fabs(sld_im) * _SCALE) 388 self.neutron_sld_im_ctl.SetValue(val) 359 389 # Compute the Cu SLD 360 390 self.cu_ka_sld_reel_ctl.SetValue(format_number(cu_real *_SCALE)) 361 self.cu_ka_sld_im_ctl.SetValue(format_number(math.fabs(cu_im )* _SCALE)) 391 val = format_number(math.fabs(cu_im )* _SCALE) 392 self.cu_ka_sld_im_ctl.SetValue(val) 362 393 # Compute the Mo SLD 363 394 self.mo_ka_sld_reel_ctl.SetValue(format_number(mo_real *_SCALE)) 364 self.mo_ka_sld_im_ctl.SetValue(format_number(math.fabs(mo_im)* _SCALE)) 395 val = format_number(math.fabs(mo_im)* _SCALE) 396 self.mo_ka_sld_im_ctl.SetValue(val) 365 397 # set incoherence and absorption 366 398 self.neutron_inc_ctl.SetValue(format_number(incoh)) … … 372 404 except: 373 405 if self.base is not None: 374 375 406 msg = "SLD Calculator: %s"%(sys.exc_value) 407 wx.PostEvent(self.base, StatusEvent(status=msg)) 376 408 else: 377 409 raise 378 410 return 379 411 if event is not None: 412 event.Skip() 380 413 381 414 class SldWindow(wx.Frame): 382 def __init__(self, parent=None, id=1, title="SLD Calculator",base=None): 383 wx.Frame.__init__(self, parent, id, title, size=( PANEL_SIZE, PANEL_SIZE)) 384 415 """ 416 """ 417 def __init__(self, parent=None, title="SLD Calculator", base=None): 418 """ 419 """ 420 wx.Frame.__init__(self, parent, title, 421 size=(PANEL_SIZE, PANEL_SIZE)) 422 """ 423 """ 385 424 self.panel = SldPanel(self, base=base) 386 425 self.Centre() … … 388 427 389 428 class ViewApp(wx.App): 429 """ 430 """ 390 431 def OnInit(self): 432 """ 433 """ 391 434 frame = SldWindow(None, -1, 'SLD Calculator') 392 435 frame.Show(True) 393 436 self.SetTopWindow(frame) 394 395 437 return True 396 438
Note: See TracChangeset
for help on using the changeset viewer.