Changeset 2db1d66 in sasview
- Timestamp:
- Jan 8, 2010 10:30:45 AM (15 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:
- 277aab4e
- Parents:
- dfa8832
- Location:
- sansview/perspectives/fitting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitting.py
r484faf7 r2db1d66 135 135 self.menu1.Append(id1, '&Simultaneous Page',simul_help) 136 136 wx.EVT_MENU(owner, id1, self.on_add_sim_page) 137 #menu for SLD Calculator 138 #self.tool_menu = wx.Menu() 139 #id_tool_menu = wx.NewId() 140 #sld_id = wx.NewId() 141 #sld_help= "Compute the scattering length density of molecules" 142 #self.tool_menu.Append(sld_id, "SLD Calculator",sld_help) 143 #wx.EVT_MENU(owner,sld_id, self.onCalculateSld) 144 137 145 138 #menu for model 146 139 menu2 = wx.Menu() … … 155 148 #create menubar items 156 149 return [(id, self.menu1, "Fitting")] 157 #(id_tool_menu, self.tool_menu,"Tools" ), 158 #(id2, menu2, "Model")] 159 160 150 161 151 def on_add_sim_page(self, event): 162 152 """ … … 170 160 171 161 self.sim_page= self.fit_panel.add_sim_page() 172 173 174 162 175 163 def help(self, evt): … … 291 279 @param return 292 280 """ 293 id =None281 id = None 294 282 if hasattr(item,"id"): 295 283 id = copy.deepcopy(item.id) … … 330 318 fitproblem.schedule_tofit(value) 331 319 332 333 334 320 def get_page_finder(self): 335 321 """ @return self.page_finder used also by simfitpage.py""" … … 353 339 value.set_model_param(names,values) 354 340 break 355 356 357 341 358 342 def split_string(self,item): 359 343 """ … … 373 357 return model_name,param_name 374 358 375 376 359 def stop_fit(self): 377 360 """ … … 383 366 is cancelled" , type="stop")) 384 367 385 386 387 368 def set_smearer(self,smearer, qmin=None, qmax=None): 388 369 """ … … 403 384 qmin= qmin, qmax= qmax) 404 385 405 406 407 386 def draw_model(self, model, data= None,smearer= None, 408 387 enable1D= True, enable2D= False, … … 431 410 qmax=qmax, 432 411 qstep=qstep) 433 434 435 412 436 413 def onFit(self): 437 414 """ … … 520 497 return 521 498 522 523 499 def ready_fit(self): 524 500 """ … … 531 507 time.sleep(0.4) 532 508 533 def onCalculateSld(self, event):534 """535 Compute the scattering length density of molecula536 """537 from sldPanel import SldWindow538 frame = SldWindow(base=self.parent)539 frame.Show(True)540 541 542 509 def _onEVT_SLICER_PANEL(self, event): 543 510 """ … … 554 521 self.parent._mgr.Update() 555 522 556 557 523 def _compute_invariant(self, event): 558 524 """ 559 525 Open the invariant panel to invariant computation 560 526 """ 561 562 527 self.panel = event.GetEventObject() 528 Plugin.on_perspective(self,event=event) 529 for plottable in self.panel.graph.plottables: 530 if plottable.name == self.panel.graph.selected_plottable: 531 data = self.copy_data(item= plottable, dy=plottable.dy) 532 533 print "_compute_invariant",data._yaxis 534 print "_compute_invariant" ,data._yunit 535 from invariant_panel import InvariantWindow 536 frame = InvariantWindow(base=self.parent, data=plottable) 537 frame.Show(True) 538 #from invariant_panel import InvariantDialog 539 #self.invariant_dlg = InvariantDialog(base=self.parent, 540 # data=plottable) 541 #if self.invariant_dlg.ShowModal() == wx.ID_OK: 542 # pass 543 #self.invariant_dlg.Destroy() 544 563 545 def _closed_fitpage(self, event): 564 546 """ … … 1087 1069 Complete plotting 1D data 1088 1070 """ 1089 1090 1071 try: 1091 1072 new_plot = Theory1D(x=x, y=y) … … 1102 1083 new_plot.is_data =False 1103 1084 1104 1105 1085 title= new_plot.name 1106 new_plot.perspective = self.get_perspective()1086 #new_plot.perspective = self.get_perspective() 1107 1087 # Pass the reset flag to let the plotting event handler 1108 1088 # know that we are replacing the whole plot … … 1111 1091 if data ==None: 1112 1092 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, 1113 title= str(title), reset=True))1093 title=str(title), reset=True)) 1114 1094 else: 1115 1095 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, … … 1123 1103 return 1124 1104 1125 1126 1127 1105 def _update2D(self, output,time=None): 1128 1106 """ … … 1140 1118 that can be plot. 1141 1119 """ 1142 1143 1144 1120 err_image = numpy.zeros(numpy.shape(image)) 1145 1121 -
sansview/perspectives/fitting/invariant_panel.py
r484faf7 r2db1d66 7 7 import sys 8 8 9 from sans.invariant import invariant 10 from sans.guiframe.dataFitting import Theory1D 9 11 from sans.guiframe.utils import format_number, check_float 10 from sans.guicomm.events import StatusEvent12 from sans.guicomm.events import NewPlotEvent, StatusEvent 11 13 12 14 # The minimum q-value to be used when extrapolating 15 Q_MINIMUM = 1e-5 16 # The maximum q-value to be used when extrapolating 17 Q_MAXIMUM = 10 18 # the number of points to consider during fit 19 NPTS = 10 20 #Default value for background 21 BACKGROUND = 0.0 22 #default value for the scale 23 SCALE = 1.0 24 #Invariant panel size 13 25 _BOX_WIDTH = 76 14 _STATICBOX_WIDTH = 35015 26 _SCALE = 1e-6 16 27 17 #SLD panel size18 28 if sys.platform.count("win32")>0: 19 _STATICBOX_WIDTH = 35029 _STATICBOX_WIDTH = 450 20 30 PANEL_WIDTH = 500 21 PANEL_HEIGHT = 60031 PANEL_HEIGHT = 700 22 32 FONT_VARIANT = 0 23 33 else: 24 _STATICBOX_WIDTH = 38034 _STATICBOX_WIDTH = 480 25 35 PANEL_WIDTH = 530 26 PANEL_HEIGHT = 60036 PANEL_HEIGHT = 700 27 37 FONT_VARIANT = 1 28 38 29 39 class InvariantPanel(wx.Panel): 30 40 """ 31 Provides the SLD calculatorGUI.41 Provides the Invariant GUI. 32 42 """ 33 43 ## Internal nickname for the window, used by the AUI manager 34 window_name = " SLD Calculator"44 window_name = "Invariant" 35 45 ## Name to appear on the window title bar 36 window_caption = " SLD Calculator"46 window_caption = "Invariant" 37 47 ## Flag to tell the AUI manager to put this panel in the center pane 38 48 CENTER_PANE = True 39 def __init__(self, parent, base=None):49 def __init__(self, parent, data=None, base=None): 40 50 wx.Panel.__init__(self, parent) 41 51 #Font size 42 52 self.SetWindowVariant(variant=FONT_VARIANT) 43 53 #Object that receive status event 44 self.base = base 54 self.parent = base 55 56 #Default power value 57 self.power_law_exponant = 4 58 59 #Data uses for computation 60 self.data = data 61 #Draw the panel 45 62 self._do_layout() 46 63 self.SetAutoLayout(True) 47 64 self.Layout() 48 65 66 def compute_invariant(self, event): 67 """ 68 compute invariant 69 """ 70 #clear outputs textctrl 71 self._reset_output() 72 background = self.background_ctl.GetValue().lstrip().rstrip() 73 scale = self.scale_ctl.GetValue().lstrip().rstrip() 74 if background == "": 75 background = 0 76 if scale == "": 77 scale = 1 78 if check_float(self.background_ctl) and check_float(self.scale_ctl): 79 inv = invariant.InvariantCalculator(data=self.data, 80 background=float(background), 81 scale=float(scale)) 82 83 low_q = self.enable_low_cbox.GetValue() 84 high_q = self.enable_high_cbox.GetValue() 85 86 #Get the number of points to extrapolated 87 npts_low = self.npts_low_ctl.GetValue() 88 if check_float(self.npts_low_ctl): 89 npts_low = float(npts_low) 90 power_low = self.power_low_ctl.GetValue() 91 if check_float(self.power_low_ctl): 92 power_low = float(power_low) 93 npts_high = self.npts_high_ctl.GetValue() 94 if check_float(self.npts_high_ctl): 95 npts_high = float(npts_high) 96 power_high = self.power_high_ctl.GetValue() 97 if check_float(self.power_high_ctl): 98 power_high = float(power_high) 99 # get the function 100 if self.power_law_low.GetValue(): 101 function_low = "power_law" 102 if self.guinier.GetValue(): 103 function_low = "guinier" 104 #power_low = None 105 106 function_high = "power_law" 107 if self.power_law_high.GetValue(): 108 function_high = "power_law" 109 #check the type of extrapolation 110 extrapolation = None 111 if low_q and not high_q: 112 extrapolation = "low" 113 elif not low_q and high_q: 114 extrapolation = "high" 115 elif low_q and high_q: 116 extrapolation = "both" 117 118 #Set the invariant calculator 119 inv.set_extrapolation(range="low", npts=npts_low, 120 function=function_low, power=power_low) 121 inv.set_extrapolation(range="high", npts=npts_high, 122 function=function_high, power=power_high) 123 #Compute invariant 124 try: 125 qstar, qstar_err = inv.get_qstar_with_error() 126 self.invariant_ctl.SetValue(format_number(qstar)) 127 self.invariant_err_ctl.SetValue(format_number(qstar)) 128 check_float(self.invariant_ctl) 129 check_float(self.invariant_err_ctl) 130 except: 131 raise 132 #msg= "Error occurs for invariant: %s"%sys.exc_value 133 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 134 #return 135 #Compute qstar extrapolated to low q range 136 #Clear the previous extrapolated plot 137 self._plot_data( name=self.data.name+" Extra_low_Q") 138 self._plot_data( name=self.data.name+" Extra_high_Q") 139 if low_q: 140 try: 141 qstar_low = inv.get_qstar_low() 142 self.invariant_low_ctl.SetValue(format_number(qstar_low)) 143 check_float(self.invariant_low_ctl) 144 #plot data 145 low_data = inv.get_extra_data_low() 146 self._plot_data(data=low_data, name=self.data.name+" Extra_low_Q") 147 except: 148 raise 149 #msg= "Error occurs for low q invariant: %s"%sys.exc_value 150 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 151 if high_q: 152 try: 153 qstar_high = inv.get_qstar_high() 154 self.invariant_high_ctl.SetValue(format_number(qstar_high)) 155 check_float(self.invariant_high_ctl) 156 #plot data 157 high_data = inv.get_extra_data_high() 158 self._plot_data(data=high_data, name=self.data.name+" Extra_high_Q") 159 except: 160 raise 161 #msg= "Error occurs for high q invariant: %s"%sys.exc_value 162 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 163 try: 164 qstar_total, qstar_total_err = inv.get_qstar_with_error(extrapolation) 165 self.invariant_total_ctl.SetValue(format_number(qstar_total)) 166 self.invariant_total_err_ctl.SetValue(format_number(qstar_total)) 167 check_float(self.invariant_total_ctl) 168 check_float(self.invariant_total_err_ctl) 169 except: 170 raise 171 #msg= "Error occurs for total invariant: %s"%sys.exc_value 172 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 173 174 contrast = self.contrast_ctl.GetValue().lstrip().rstrip() 175 if not check_float(self.contrast_ctl): 176 contrast = None 177 else: 178 contrast = float(contrast) 179 porod_const = self.porod_const_ctl.GetValue().lstrip().rstrip() 180 if not check_float(self.porod_const_ctl): 181 porod_const = None 182 else: 183 porod_const = float(porod_const) 184 try: 185 v, dv = inv.get_volume_fraction_with_error(contrast=contrast) 186 self.volume_ctl.SetValue(format_number(v)) 187 self.volume_err_ctl.SetValue(format_number(dv)) 188 check_float(self.volume_ctl) 189 check_float(self.volume_err_ctl) 190 except: 191 raise 192 #msg= "Error occurs for volume fraction: %s"%sys.exc_value 193 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 194 try: 195 s, ds = inv.get_surface_with_error(contrast=contrast, 196 porod_const=porod_const) 197 self.surface_ctl.SetValue(format_number(s)) 198 self.surface_err_ctl.SetValue(format_number(ds)) 199 check_float(self.surface_ctl) 200 check_float(self.surface_err_ctl) 201 except: 202 raise 203 #msg= "Error occurs for surface: %s"%sys.exc_value 204 #wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 205 206 else: 207 msg= "invariant: Need float for background and scale" 208 wx.PostEvent(self.parent, StatusEvent(status= msg, type="stop")) 209 return 210 211 def _plot_data(self, data=None, name="Unknown"): 212 """ 213 Receive a data and post a NewPlotEvent to parent 214 @param data: data created frome xtrapolation to plot 215 @param name: Data's name to use for the legend 216 """ 217 # Create a plottable data 218 new_plot = Theory1D(x=[], y=[], dy=None) 219 if data is not None: 220 new_plot.copy_from_datainfo(data) 221 data.clone_without_data(clone=new_plot) 222 223 new_plot.name = name 224 title = self.data.name 225 new_plot.xaxis(self.data._xaxis, self.data._xunit) 226 new_plot.yaxis(self.data._yaxis, self.data._yunit) 227 new_plot.group_id = self.data.group_id 228 new_plot.id = self.data.id + name 229 ##post data to plot 230 wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=title)) 231 232 def _reset_output(self): 233 """ 234 clear outputs textcrtl 235 """ 236 self.invariant_ctl.Clear() 237 self.invariant_err_ctl.Clear() 238 self.invariant_low_ctl.Clear() 239 self.invariant_high_ctl.Clear() 240 self.invariant_total_ctl.Clear() 241 self.invariant_total_err_ctl.Clear() 242 self.volume_ctl.Clear() 243 self.volume_err_ctl.Clear() 244 self.surface_ctl.Clear() 245 self.surface_err_ctl.Clear() 246 49 247 def _do_layout(self): 50 248 """ … … 55 253 unit_surface = '' 56 254 uncertainty = "+/-" 57 sizer_input = wx.GridBagSizer(5,5) 255 npts_hint_txt = "Number of points to consider during extrapolation." 256 power_hint_txt = "Exponent to apply to the Power_law function." 257 258 sizer_input = wx.FlexGridSizer(5,4)#wx.GridBagSizer(5,5) 58 259 sizer_output = wx.GridBagSizer(5,5) 59 260 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 60 sizer1 = wx.BoxSizer(wx.HORIZONTAL) 61 sizer2 = wx.BoxSizer(wx.HORIZONTAL) 261 262 sizer1 = wx.BoxSizer(wx.VERTICAL) 263 sizer2 = wx.BoxSizer(wx.VERTICAL) 62 264 sizer3 = wx.BoxSizer(wx.HORIZONTAL) 63 265 266 sizer1.SetMinSize((_STATICBOX_WIDTH, -1)) 267 sizer2.SetMinSize((_STATICBOX_WIDTH, -1)) 268 sizer3.SetMinSize((_STATICBOX_WIDTH, -1)) 64 269 #---------inputs---------------- 270 data_txt = wx.StaticText(self, -1, 'Data : ') 271 data_name = "" 272 data_range = "[? - ?]" 273 if self.data is not None: 274 data_name = self.data.name 275 data_qmin = min (self.data.x) 276 data_qmax = max (self.data.x) 277 data_range = "[%s - %s]"%(str(data_qmin), str(data_qmax)) 278 279 data_name_txt = wx.StaticText(self, -1, str(data_name)) 280 data_range_txt = wx.StaticText(self, -1, "Range : ") 281 data_range_value_txt = wx.StaticText(self, -1, str(data_range)) 282 65 283 background_txt = wx.StaticText(self, -1, 'Background') 66 284 self.background_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 285 self.background_ctl.SetValue(str(BACKGROUND)) 67 286 self.background_ctl.SetToolTipString("Background to subtract to data.") 68 287 scale_txt = wx.StaticText(self, -1, 'Scale') 69 288 self.scale_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 289 self.scale_ctl.SetValue(str(SCALE)) 70 290 self.scale_ctl.SetToolTipString("Scale to apply to data.") 71 291 contrast_txt = wx.StaticText(self, -1, 'Contrast') … … 76 296 self.porod_const_ctl.SetToolTipString("Invariant in q range.") 77 297 78 iy = 0 79 ix = 0 80 sizer_input.Add(background_txt,(iy, ix),(1,1),\ 81 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 82 ix +=1 83 sizer_input.Add(self.background_ctl,(iy, ix),(1,1),\ 84 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 85 iy += 1 86 ix = 0 87 sizer_input.Add(scale_txt,(iy, ix),(1,1),\ 88 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 89 ix += 1 90 sizer_input.Add(self.scale_ctl, (iy, ix), (1,1),\ 91 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 92 iy += 1 93 ix = 0 94 sizer_input.Add(contrast_txt, (iy, ix),(1,1),\ 95 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 96 ix += 1 97 sizer_input.Add(self.contrast_ctl,(iy, ix),(1,1),\ 98 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 99 iy += 1 100 ix = 0 101 sizer_input.Add(porod_const_txt, (iy, ix),(1,1),\ 102 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 103 ix += 1 104 sizer_input.Add(self.porod_const_ctl,(iy, ix),(1,1),\ 105 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 106 298 sizer_input.Add(data_txt, 0, wx.LEFT, 5) 299 sizer_input.Add(data_name_txt) 300 sizer_input.Add(data_range_txt, 0, wx.LEFT, 10) 301 sizer_input.Add(data_range_value_txt) 302 sizer_input.Add(background_txt, 0, wx.ALL, 5) 303 sizer_input.Add(self.background_ctl, 0, wx.ALL, 5) 304 sizer_input.Add((10,10)) 305 sizer_input.Add((10,10)) 306 sizer_input.Add(scale_txt, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 307 sizer_input.Add(self.scale_ctl, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 308 sizer_input.Add((10,10)) 309 sizer_input.Add((10,10)) 310 sizer_input.Add(contrast_txt, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 311 sizer_input.Add(self.contrast_ctl, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 312 sizer_input.Add((10,10)) 313 sizer_input.Add((10,10)) 314 sizer_input.Add(porod_const_txt, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 315 sizer_input.Add(self.porod_const_ctl, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 5) 316 #-------------Extrapolation sizer---------------- 107 317 sizer_low_q = wx.GridBagSizer(5,5) 318 319 self.enable_low_cbox = wx.CheckBox(self, -1, "Enable low Q") 320 self.enable_low_cbox.SetValue(False) 321 self.enable_high_cbox = wx.CheckBox(self, -1, "Enable High Q") 322 self.enable_high_cbox.SetValue(False) 323 108 324 self.guinier = wx.RadioButton(self, -1, 'Guinier', 109 (10, 10), 325 (10, 10),style=wx.RB_GROUP) 110 326 self.power_law_low = wx.RadioButton(self, -1, 'Power_law', (10, 10)) 111 327 #self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, … … 115 331 #MAC needs SetValue 116 332 self.guinier.SetValue(True) 117 power_low_txt = wx.StaticText(self, -1, 'Power') 118 self.power_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 119 self.power_low_ctl.SetToolTipString("Power to apply to the\ 120 Power_law function.") 333 334 npts_low_txt = wx.StaticText(self, -1, 'Npts') 335 self.npts_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 336 self.npts_low_ctl.SetValue(str(NPTS)) 337 self.power_low_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 338 self.power_low_ctl.SetValue(str(self.power_law_exponant)) 339 self.power_low_ctl.SetToolTipString(power_hint_txt) 121 340 iy = 0 122 341 ix = 0 342 sizer_low_q.Add(self.guinier,(iy, ix),(1,1), 343 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 344 iy += 1 345 ix = 0 123 346 sizer_low_q.Add(self.power_law_low,(iy, ix),(1,1), 124 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)125 iy += 1126 ix = 0127 sizer_low_q.Add(power_low_txt,(iy, ix),(1,1),128 347 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 129 348 ix += 1 … … 132 351 iy += 1 133 352 ix = 0 134 sizer_low_q.Add(self.guinier,(iy, ix),(1,1), 135 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 136 353 sizer_low_q.Add(npts_low_txt,(iy, ix),(1,1), 354 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 355 ix += 1 356 sizer_low_q.Add(self.npts_low_ctl, (iy, ix), (1,1), 357 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 358 iy += 1 359 ix = 0 360 sizer_low_q.Add(self.enable_low_cbox,(iy, ix),(1,1), 361 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 137 362 sizer_high_q = wx.GridBagSizer(5,5) 138 self.power_law_high = wx.RadioButton(self, -1, 'Power_law', (10, 10)) 363 self.power_law_high = wx.RadioButton(self, -1, 'Power_law', 364 (10, 10), style=wx.RB_GROUP) 139 365 #self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 140 366 # id=self.power_law_high.GetId()) 141 367 #MAC needs SetValue 142 368 self.power_law_high.SetValue(True) 143 power_high_txt = wx.StaticText(self, -1, 'Power') 144 self.power_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,-1)) 145 self.power_high_ctl.SetToolTipString("Power to apply to the\ 146 Power_law function.") 147 iy = 0 369 npts_high_txt = wx.StaticText(self, -1, 'Npts') 370 self.npts_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 371 self.npts_high_ctl.SetValue(str(NPTS)) 372 self.power_high_ctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/3, -1)) 373 self.power_high_ctl.SetValue(str(self.power_law_exponant)) 374 self.power_high_ctl.SetToolTipString(power_hint_txt) 375 376 iy = 1 148 377 ix = 0 149 378 sizer_high_q.Add(self.power_law_high,(iy, ix),(1,1), 150 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)151 iy += 1152 ix = 0153 sizer_high_q.Add(power_high_txt,(iy, ix),(1,1),154 379 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 155 380 ix += 1 156 381 sizer_high_q.Add(self.power_high_ctl, (iy, ix), (1,1), 157 382 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 383 iy += 1 384 ix = 0 385 sizer_high_q.Add(npts_high_txt,(iy, ix),(1,1), 386 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 387 ix += 1 388 sizer_high_q.Add(self.npts_high_ctl, (iy, ix), (1,1), 389 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 390 iy += 1 391 ix = 0 392 sizer_high_q.Add(self.enable_high_cbox,(iy, ix),(1,1), 393 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 158 394 159 395 high_q_box = wx.StaticBox(self, -1, "High Q") … … 165 401 boxsizer_low_q.Add(sizer_low_q) 166 402 167 sizer_extrapolation = wx.BoxSizer(wx.HORIZONTAL) 403 #-------------Enable extrapolation------- 404 extra_hint = "Extrapolation Maximum Range: " 405 extra_hint_txt= wx.StaticText(self, -1,extra_hint ) 406 enable_sizer = wx.BoxSizer(wx.HORIZONTAL) 407 extra_range = "[%s - %s]"%(str(Q_MINIMUM), str(Q_MAXIMUM)) 408 extra_range_value_txt = wx.StaticText(self, -1, str(extra_range)) 409 enable_sizer.Add(extra_hint_txt, 0, wx.ALL, 5) 410 enable_sizer.Add(extra_range_value_txt, 0, wx.ALL, 5) 411 412 type_extrapolation_sizer = wx.BoxSizer(wx.HORIZONTAL) 413 type_extrapolation_sizer.Add((10,10)) 414 type_extrapolation_sizer.Add(boxsizer_low_q, 0, wx.ALL, 10) 415 type_extrapolation_sizer.Add((20,20)) 416 type_extrapolation_sizer.Add(boxsizer_high_q, 0, wx.ALL, 10) 417 type_extrapolation_sizer.Add((10,10)) 418 168 419 extrapolation_box = wx.StaticBox(self, -1, "Extrapolation") 169 boxsizer_extra = wx.StaticBoxSizer(extrapolation_box, wx.HORIZONTAL) 170 boxsizer_extra.Add(boxsizer_low_q) 171 boxsizer_extra.Add((10,10)) 172 boxsizer_extra.Add(boxsizer_high_q) 420 boxsizer_extra = wx.StaticBoxSizer(extrapolation_box, wx.VERTICAL) 421 boxsizer_extra.Add(enable_sizer, 0, wx.ALL, 10) 422 boxsizer_extra.Add(type_extrapolation_sizer) 173 423 174 424 inputbox = wx.StaticBox(self, -1, "Input") … … 176 426 boxsizer1.SetMinSize((_STATICBOX_WIDTH,-1)) 177 427 boxsizer1.Add(sizer_input) 178 boxsizer1.Add(boxsizer_extra) 179 428 boxsizer1.Add(boxsizer_extra, 0, wx.ALL, 10) 180 429 sizer1.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) 430 181 431 #---------Outputs sizer-------- 182 432 invariant_txt = wx.StaticText(self, -1, 'Invariant') … … 245 495 ix +=1 246 496 sizer_output.Add(self.invariant_high_ctl, (iy, ix), (1,1), 247 wx.EXPAND|wx.ADJUST_MINSIZE, 0)497 wx.EXPAND|wx.ADJUST_MINSIZE, ) 248 498 ix += 2 249 499 sizer_output.Add(invariant_high_units_txt, (iy, ix), (1,1), … … 279 529 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 280 530 ix +=1 281 sizer_output.Add(invariant_total_units_txt 282 ,(iy, ix),(1,1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)531 sizer_output.Add(invariant_total_units_txt,(iy, ix), 532 (1,1),wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 283 533 iy += 1 284 534 ix = 0 … … 320 570 sizer2.Add(boxsizer2,0, wx.EXPAND|wx.ALL, 10) 321 571 #-----Button sizer------------ 322 323 572 id = wx.NewId() 324 573 button_calculate = wx.Button(self, id, "Compute") … … 337 586 self.SetSizer(vbox) 338 587 339 def compute_invariant(self, event):340 """341 compute invariant342 """343 344 588 class InvariantDialog(wx.Dialog): 345 def __init__(self, parent=None, id=1, title="Invariant",base=None):589 def __init__(self, parent=None, id=1,data=None, title="Invariant",base=None): 346 590 wx.Dialog.__init__(self, parent, id, title, size=( PANEL_WIDTH, 347 591 PANEL_HEIGHT)) 348 349 self.panel = InvariantPanel(self, base=base) 592 self.panel = InvariantPanel(self, data=data, base=base) 593 self.Centre() 594 self.Show(True) 595 596 class InvariantWindow(wx.Frame): 597 def __init__(self, parent=None, id=1,data=None, title="SLD Calculator",base=None): 598 wx.Frame.__init__(self, parent, id, title, size=( PANEL_WIDTH, 599 PANEL_HEIGHT)) 600 601 self.panel = InvariantPanel(self, data=data, base=base) 350 602 self.Centre() 351 603 self.Show(True) … … 354 606 def OnInit(self): 355 607 wx.InitAllImageHandlers() 356 357 dialog = InvariantDialog(None) 358 if dialog.ShowModal() == wx.ID_OK: 359 pass 360 dialog.Destroy() 361 362 return 1 608 frame = InvariantWindow() 609 frame.Show(True) 610 self.SetTopWindow(frame) 611 612 return True 613 #wx.InitAllImageHandlers() 614 #dialog = InvariantDialog(None) 615 #if dialog.ShowModal() == wx.ID_OK: 616 # pass 617 #dialog.Destroy() 618 #return 1 363 619 364 620 # end of class MyApp
Note: See TracChangeset
for help on using the changeset viewer.