Changeset c80c06f in sasview
- Timestamp:
- Feb 1, 2009 10:40:18 PM (16 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:
- 1374fbe4
- Parents:
- 68dada4
- Location:
- sansview/perspectives/fitting
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansview/perspectives/fitting/fitting.py
r68dada4 rc80c06f 445 445 wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value)) 446 446 return 447 # need to check this print "new model " 447 448 new_model=Model(model) 448 449 param=value.get_model_param() … … 458 459 #new_model.set( exec "%s"%(param_nam) = param_value) 459 460 new_model.parameterset[ param_name].set( param_value ) 460 461 461 462 self.fitter.set_model(new_model, self.id, pars) 462 463 self.fitter.set_data(metadata,self.id,qmin,qmax,ymin,ymax) -
sansview/perspectives/fitting/new_fitpage1D.py
r68dada4 rc80c06f 5 5 import copy 6 6 import sans.models.dispersion_models 7 from sans.guicomm.events import StatusEvent 7 from sans.guicomm.events import StatusEvent 8 from modelpage import ModelPage 9 from modelpage import format_number 8 10 (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent() 9 11 _BOX_WIDTH = 80 10 12 11 def format_number(value, high=False):12 """13 Return a float in a standardized, human-readable formatted string14 """15 try:16 value = float(value)17 except:18 print "returning 0"19 return "0"20 21 if high:22 return "%-6.4g" % value23 else:24 return "%-5.3g" % value25 13 26 from modelpage import format_number 27 from modelpage import ModelPage 14 28 15 class FitPage1D(ModelPage): 29 16 """ … … 52 39 #panel interface 53 40 self.vbox = wx.BoxSizer(wx.VERTICAL) 41 self.sizer10 = wx.GridBagSizer(5,5) 54 42 self.sizer9 = wx.GridBagSizer(5,5) 55 43 self.sizer8 = wx.GridBagSizer(5,5) … … 76 64 self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 77 65 self.vbox.Add(self.sizer6) 66 #combox box for type of dispersion 67 self.vbox.Add(self.sizer7) 78 68 #dispersion parameters layer 79 self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 80 self.vbox.Add(self.sizer7) 69 self.vbox.Add(self.sizer8) 81 70 #fit info layer 82 71 self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 83 self.vbox.Add(self.sizer 8)72 self.vbox.Add(self.sizer9) 84 73 #close layer 85 74 self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0) 86 self.vbox.Add(self.sizer 9)75 self.vbox.Add(self.sizer10) 87 76 88 77 #---------sizer 1 draw-------------------------------- … … 117 106 #---------sizer 2 draw-------------------------------- 118 107 ix = 0 119 iy = 0108 iy = 1 120 109 #set maximum range for x in linear scale 121 110 self.text4_3 = wx.StaticText(self, -1, 'Maximum Data Range(Linear)', style=wx.ALIGN_LEFT) … … 136 125 #----sizer 3 draw-------------------------------- 137 126 ix = 0 138 iy = 0127 iy = 1 139 128 self.sizer3.Add(wx.StaticText(self,-1,'Instrument Smearing'),(iy,ix),(1,1)\ 140 129 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 159 148 self.disable_disp = wx.RadioButton(self, -1, 'No', (10, 10), style=wx.RB_GROUP) 160 149 self.enable_disp = wx.RadioButton(self, -1, 'Yes', (10, 30)) 161 #self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.disable_disp.GetId())162 #self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.enable_disp.GetId())150 self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.disable_disp.GetId()) 151 self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.enable_disp.GetId()) 163 152 ix= 0 164 153 iy=1 … … 169 158 ix += 1 170 159 self.sizer6.Add(self.disable_disp ,(iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 171 172 173 #---------sizer 8 draw---------------------------------------- 160 ix =0 161 iy+=1 162 self.sizer6.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 163 164 165 #---------sizer 9 draw---------------------------------------- 174 166 self.tcChi = wx.StaticText(self, -1, str(0), style=wx.ALIGN_LEFT) 175 167 self.tcChi.Hide() … … 209 201 ix = 0 210 202 iy = 1 211 self.sizer 8.Add(wx.StaticText(self, -1, 'Fitting Range'),(iy, ix),(1,1),\203 self.sizer9.Add(wx.StaticText(self, -1, 'Fitting Range'),(iy, ix),(1,1),\ 212 204 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 213 205 ix += 1 214 self.sizer 8.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\206 self.sizer9.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\ 215 207 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 216 208 ix += 1 217 self.sizer 8.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\209 self.sizer9.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\ 218 210 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 219 211 ix += 1 220 self.sizer 8.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\212 self.sizer9.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\ 221 213 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 222 214 ix = 0 223 215 iy += 1 224 self.sizer 8.Add(wx.StaticText(self, -1, 'x range'),(iy, ix),(1,1),\216 self.sizer9.Add(wx.StaticText(self, -1, 'x range'),(iy, ix),(1,1),\ 225 217 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 226 218 ix += 1 227 self.sizer 8.Add(self.xmin,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)228 ix += 1 229 self.sizer 8.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)230 ix += 1 231 self.sizer 8.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)219 self.sizer9.Add(self.xmin,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 220 ix += 1 221 self.sizer9.Add(self.xmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 222 ix += 1 223 self.sizer9.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 232 224 ix = 0 233 225 iy += 1 234 self.sizer 8.Add(self.text1_1,(iy,ix),(1,1),\226 self.sizer9.Add(self.text1_1,(iy,ix),(1,1),\ 235 227 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 236 228 ix += 1 237 self.sizer 8.Add(self.tcChi,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)229 self.sizer9.Add(self.tcChi,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 238 230 ix +=2 239 self.sizer 8.Add(self.btFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)231 self.sizer9.Add(self.btFit,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 240 232 ix =0 241 233 iy+=1 242 self.sizer 8.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)243 #----------sizer 9draw------------------------------------------------------234 self.sizer9.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 235 #----------sizer 10 draw------------------------------------------------------ 244 236 id = wx.NewId() 245 237 self.btClose =wx.Button(self,id,'Close') … … 247 239 self.btClose.SetToolTipString("Close page.") 248 240 249 ix= 0241 ix= 3 250 242 iy= 1 251 self.sizer 9.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)252 ix += 3253 self.sizer 9.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)243 self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 244 ix +=1 245 self.sizer10.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 254 246 ix =0 255 247 iy+=1 256 self.sizer 9.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)248 self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 257 249 258 250 # contains link between model ,all its parameters, and panel organization … … 278 270 self.Layout() 279 271 self.GrandParent.GetSizer().Layout() 280 281 282 283 284 285 272 273 286 274 def compute_chisqr(self): 287 275 """ @param fn: function that return model value … … 308 296 if numpy.isfinite(item): 309 297 sum +=item 310 self.tcChi.Set Value(format_number(math.fabs(sum)))298 self.tcChi.SetLabel(format_number(math.fabs(sum))) 311 299 except: 312 300 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 313 301 "Chisqr cannot be compute: %s"% sys.exc_value)) 314 302 315 303 def _on_select_model(self,event): 304 """ 305 react when a model is selected from page's combo box 306 post an event to its owner to draw an appropriate theory 307 """ 308 self.btFit.SetFocus() 309 for item in self.model_list_box.itervalues(): 310 name = item.__name__ 311 if hasattr(item, "name"): 312 name = item.name 313 #print "fitpage: _on_select_model model name",name ,event.GetString() 314 if name ==event.GetString(): 315 try: 316 self.model=item() 317 evt = ModelEventbox(model=self.model,name=name) 318 wx.PostEvent(self.event_owner, evt) 319 #self.model= item() 320 #self.set_panel(self.model) 321 except: 322 raise #ValueError,"model.name is not equal to model class name" 323 break 316 324 def onFit(self,event): 317 325 """ signal for fitting""" … … 329 337 "Select at least on parameter to fit ")) 330 338 331 332 def _on_select_model(self,event): 333 """ 334 react when a model is selected from page's combo box 335 post an event to its owner to draw an appropriate theory 336 """ 337 self.btFit.SetFocus() 338 for item in self.model_list_box.itervalues(): 339 name = item.__name__ 340 if hasattr(item, "name"): 341 name = item.name 342 #print "fitpage: _on_select_model model name",name ,event.GetString() 343 if name ==event.GetString(): 344 try: 345 self.model=item() 346 evt = ModelEventbox(model=self.model,name=name) 347 wx.PostEvent(self.event_owner, evt) 348 #self.model= item() 349 #self.set_panel(self.model) 350 except: 351 raise #ValueError,"model.name is not equal to model class name" 352 break 353 339 354 340 def _onTextEnter(self,event): 355 341 """ … … 368 354 "Drawing Error:wrong value entered %s"% sys.exc_value)) 369 355 370 def checkFitRange(self): 371 """ 372 Check the validity of fitting range 373 @note: xmin should always be less than xmax or else each control box 374 background is colored in pink. 375 """ 376 377 flag = True 378 valueMin = self.xmin.GetValue() 379 valueMax = self.xmax.GetValue() 380 # Check for possible values entered 381 #print "fitpage: checkfitrange:",valueMin,valueMax 382 try: 383 if (float(valueMax)> float(valueMin)): 384 self.xmax.SetBackgroundColour(wx.WHITE) 385 self.xmin.SetBackgroundColour(wx.WHITE) 386 else: 387 flag = False 388 self.xmin.SetBackgroundColour("pink") 389 self.xmax.SetBackgroundColour("pink") 390 except: 391 flag = False 392 self.xmin.SetBackgroundColour("pink") 393 self.xmax.SetBackgroundColour("pink") 394 395 self.xmin.Refresh() 396 self.xmax.Refresh() 397 return flag 398 399 356 400 357 401 358 def get_param_list(self): … … 411 368 raise ValueError,"missing parameter to fit" 412 369 413 414 def set_panel(self,model): 370 371 372 def old_set_panel(self,model): 415 373 """ 416 374 Build the panel from the model content 417 375 @param model: the model selected in combo box for fitting purpose 418 376 """ 419 self.sizer2.Clear(True)420 377 self.sizer5.Clear(True) 421 self.sizer6.Clear(True)422 378 self.parameters = [] 423 379 self.param_toFit=[] … … 426 382 #print "fitpage1D : dispersion list",self.model.getDispParamList() 427 383 keys.sort() 428 disp_list=self.model.getDispParamList()429 fixed=self.model.fixed430 print "fixed",fixed431 #model.setParam("scale", 2)432 #print "model sphere scale fixed?", self.model.is_fittable("scale")433 ip=0434 iq=1435 436 384 ik=0 437 385 im=1 438 if len(disp_list)>0: 439 disp = wx.StaticText(self, -1, 'Dispersion') 440 self.sizer5.Add(disp,( iq, ip),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 441 ip += 1 442 values = wx.StaticText(self, -1, 'Values') 443 self.sizer5.Add(values,( iq, ip),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 444 445 disp_list.sort() 386 446 387 iy = 1 447 388 ix = 0 448 389 self.cb1 = wx.CheckBox(self, -1,"Select all", (10, 10)) 449 390 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param) 450 self.sizer 2.Add(self.cb1,(iy, ix),(1,1),\391 self.sizer5.Add(self.cb1,(iy, ix),(1,1),\ 451 392 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 452 393 ix +=1 453 394 self.text2_2 = wx.StaticText(self, -1, 'Values') 454 self.sizer 2.Add(self.text2_2,(iy, ix),(1,1),\395 self.sizer5.Add(self.text2_2,(iy, ix),(1,1),\ 455 396 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 456 397 ix +=2 457 398 self.text2_3 = wx.StaticText(self, -1, 'Errors') 458 self.sizer 2.Add(self.text2_3,(iy, ix),(1,1),\399 self.sizer5.Add(self.text2_3,(iy, ix),(1,1),\ 459 400 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 460 401 self.text2_3.Hide() 461 402 ix +=1 462 403 self.text2_4 = wx.StaticText(self, -1, 'Units') 463 self.sizer 2.Add(self.text2_4,(iy, ix),(1,1),\404 self.sizer5.Add(self.text2_4,(iy, ix),(1,1),\ 464 405 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 465 406 self.text2_4.Hide() 466 #print "keys", keys 467 #print "disp_list", disp_list 468 #print "fix_list",fixed 407 disp_list=self.model.getDispParamList() 469 408 for item in keys: 470 409 if not item in disp_list: … … 474 413 cb = wx.CheckBox(self, -1, item, (10, 10)) 475 414 cb.SetValue(False) 476 self.sizer 2.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)415 self.sizer5.Add( cb,( iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 477 416 wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param) 478 417 … … 483 422 ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter) 484 423 ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter) 485 self.sizer 2.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)424 self.sizer5.Add(ctl1, (iy,ix),(1,1), wx.EXPAND) 486 425 487 426 ix += 1 488 427 text2=wx.StaticText(self, -1, '+/-') 489 self.sizer 2.Add(text2,(iy, ix),(1,1),\428 self.sizer5.Add(text2,(iy, ix),(1,1),\ 490 429 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 491 430 text2.Hide() 492 431 ix += 1 493 432 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER) 494 self.sizer 2.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)433 self.sizer5.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 495 434 ctl2.Hide() 496 435 ix +=1 … … 500 439 except: 501 440 units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT) 502 self.sizer2.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 441 self.sizer5.Add(units, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 442 """ 503 443 else: 504 444 if not item in fixed: … … 532 472 im += 1 533 473 #save data 534 474 """ 535 475 self.parameters.append([cb,ctl1,text2,ctl2]) 536 476 537 477 iy+=1 538 self.sizer 2.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)478 self.sizer5.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 539 479 540 480 #Display units text on panel … … 583 523 self.set_model_parameter() 584 524 585 def set_model_parameter(self): 586 if len(self.parameters) !=0 and self.model !=None: 587 # Flag to register when a parameter has changed. 588 is_modified = False 589 for item in self.fixed_param: 590 591 try: 592 name=str(item[0]) 593 value= float(item[1].GetValue()) 594 # print "model para", name,value 595 # If the value of the parameter has changed, 596 # update the model and set the is_modified flag 597 if value != self.model.getParam(name): 598 self.model.setParam(name,value) 599 is_modified = True 600 except: 601 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 602 "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) 603 604 for item in self.parameters: 605 # print "paramters",str(item[0].GetLabelText()) 606 try: 607 name=str(item[0].GetLabelText()) 608 value= float(item[1].GetValue()) 609 # print "model para", name,value 610 # If the value of the parameter has changed, 611 # update the model and set the is_modified flag 612 if value != self.model.getParam(name): 613 self.model.setParam(name,value) 614 is_modified = True 615 except: 616 wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\ 617 "Model Drawing Error:wrong value entered : %s"% sys.exc_value)) 618 619 # Here we should check whether the boundaries have been modified. 620 # If qmin and qmax have been modified, update qmin and qmax and 621 # set the is_modified flag to True 622 if float(self.xmin.GetValue()) != self.qmin: 623 self.qmin = float(self.xmin.GetValue()) 624 is_modified = True 625 if float(self.xmax.GetValue()) != self.qmax: 626 self.qmax = float(self.xmax.GetValue()) 627 is_modified = True 628 629 if is_modified: 630 self.manager.redraw_model(qmin=self.qmin, qmax=self.qmax) 631 525 632 526 def select_all_param(self,event): 633 527 """ -
sansview/perspectives/fitting/new_fitpanel.py
r68dada4 rc80c06f 8 8 9 9 10 11 class FitPanel(wx.Panel):10 class FitPanel(wx.aui.AuiNotebook): 11 #class FitPanel(wx.aui.AuiNotebook,wx.panel): 12 12 """ 13 13 FitPanel class contains fields allowing to fit models and data … … 21 21 window_caption = "Fit Panel " 22 22 CENTER_PANE = True 23 24 25 23 def __init__(self, parent, *args, **kwargs): 26 wx.Panel.__init__(self, parent, *args, **kwargs) 24 25 wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS ) 26 27 27 self.manager=None 28 28 self.parent=parent 29 29 self.event_owner=None 30 #self.menu_mng = models.ModelManager() 31 #self.nb = wx.Notebook(self) 32 #self.nb = wx.aui.AuiNotebook(self,-1, style=wx.aui.AUI_NB_TAB_SPLIT ) 33 self.nb = wx.aui.AuiNotebook(self,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS ) 34 self.sizer = wx.BoxSizer() 35 self.sizer.Add(self.nb, 1, wx.EXPAND) 30 31 pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE 32 self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePage) 33 36 34 #Creating an initial page for simultaneous fitting 37 35 from simfitpage import SimultaneousFitPage 38 self.sim_page = SimultaneousFitPage(self .nb, -1)39 40 #self.fit_panel.add_page(self.sim_page,"Simultaneous Fit")41 self.nb.AddPage(self.sim_page,"Simultaneous Fit") 42 #(wxWindow* page, const wxString& caption, bool select = false, const wxBitmap& bitmap =36 self.sim_page = SimultaneousFitPage(self, -1) 37 self.AddPage(self.sim_page,"Simultaneous Fit") 38 39 40 43 41 #dictionary of miodel {model class name, model class} 44 42 self.model_list_box={} … … 53 51 self.count=0 54 52 #updating the panel 55 self.nb.Update() 56 self.SetSizer(self.sizer) 57 self.sizer.Fit(self) 53 self.Update() 58 54 self.Center() 59 55 def onClosePage(self, event): 56 self.ToggleWindowStyle(wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB) 57 print "went here",self.get_current_page(), self.GetPage(0) 58 #event.Skip() 59 if self.GetPageCount() <= 2: 60 print "wente here" 61 62 # Prevent last tab from being closed 63 self.ToggleWindowStyle(~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB) 64 65 66 67 60 68 61 69 … … 91 99 if data.__class__.__name__=='Data2D': 92 100 from fitpage2D import FitPage2D 93 panel = FitPage2D(self .nb,data, -1)101 panel = FitPage2D(self,data, -1) 94 102 95 103 else: 96 104 97 105 from fitpage1D import FitPage1D 98 panel = FitPage1D(self .nb,data, -1)106 panel = FitPage1D(self,data, -1) 99 107 m_name= "M"+str(self.count) 100 108 panel.set_manager(self.manager) 101 109 panel.set_owner(self.event_owner) 102 110 103 self. nb.AddPage(page=panel,caption=name,select=True)111 self.AddPage(page=panel,caption=name,select=True) 104 112 panel.populate_box( self.model_list_box) 105 113 self.fit_page_name = name … … 115 123 """ 116 124 from modelpage import ModelPage 117 panel = ModelPage(self .nb,model,page_title, -1)125 panel = ModelPage(self,model,page_title, -1) 118 126 panel.set_manager(self.manager) 119 127 panel.set_owner(self.event_owner) 120 #self.nb.AddPage(page=panel,text=page_title,select=True) 121 self.nb.AddPage(page=panel,caption="Model",select=True) 128 self.AddPage(page=panel,caption="Model",select=True) 122 129 panel.populate_box( self.model_list_box) 123 130 self.draw_model_name=page_title 124 self.model_page_number=self. nb.GetSelection()125 self.model_page=self. nb.GetPage(self.nb.GetSelection())131 self.model_page_number=self.GetSelection() 132 self.model_page=self.GetPage(self.GetSelection()) 126 133 127 134 … … 153 160 self.model_page.select_model(model, page_title) 154 161 155 def get_notebook(self): 156 """ 157 @return self.nb: return its own notebook mostly used by fitting module 158 """ 159 return self.nb 162 def get_current_page(self): 163 """ 164 @return the current page selected 165 """ 166 #return self.nb.GetCurrentPage() 167 return self.GetPage(self.GetSelection() ) 168 160 169 161 def get_page(self, n): 162 """ 163 @return page at position n 164 @param n: page number 165 """ 166 return self.nb.GetPage(n) 167 168 169 def get_page_count(self): 170 """ @return number total of pages contained in notebook""" 171 return self.nb.GetPageCount() 172 173 174 def get_current_page(self): 175 """ 176 @return the current page selected 177 """ 178 #return self.nb.GetCurrentPage() 179 return self.nb.GetPage(self.nb.GetSelection() ) 180 181 def get_selected_page(self): 182 """ @return the page just selected by the user """ 183 return self.nb.GetPage(self.nb.GetSelection()) 184 185 186 def get_page_number(self): 187 return self.nb.GetSelection() 188 189 def onClose(self, page=None,page_number=None): 170 def old_onClose(self, page=None,page_number=None): 190 171 """ 191 172 close the current page except the simpage. remove each check box link to the model
Note: See TracChangeset
for help on using the changeset viewer.