Index: sansview/perspectives/fitting/fit_thread.py
===================================================================
--- sansview/perspectives/fitting/fit_thread.py	(revision 98be89f5034ccbeb3bb62fe26bab9a4bf8d34782)
+++ sansview/perspectives/fitting/fit_thread.py	(revision 925a30e1970e2e81bed1969735af0a4824905734)
@@ -175,5 +175,6 @@
             raise
         except:
-            wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value))
-            return 
+            raise
+            #wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value))
+            #return 
     
Index: sansview/perspectives/fitting/fitpanel.py
===================================================================
--- sansview/perspectives/fitting/fitpanel.py	(revision b491d6eaf39336ad983e4d15887bfc94c47da57b)
+++ sansview/perspectives/fitting/fitpanel.py	(revision 925a30e1970e2e81bed1969735af0a4824905734)
@@ -9,5 +9,5 @@
 (FitPageEvent, EVT_FIT_PAGE)   = wx.lib.newevent.NewEvent()
 class FitPanel(wx.aui.AuiNotebook):    
-#class FitPanel(wx.aui.AuiNotebook,wx.panel):
+
     """
         FitPanel class contains fields allowing to fit  models and  data
@@ -22,6 +22,4 @@
     CENTER_PANE = True
     def __init__(self, parent, *args, **kwargs):
-        
-        #wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS )
         wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_DEFAULT_STYLE  )
         
@@ -38,11 +36,6 @@
         self.about_page = PanelAbout(self, -1)
         self.AddPage(self.about_page,"welcome!")
-        #self.about_page.Disable()
-        #Creating a page for simultaneous fitting
+      
        
-        
-        self._mgr = self.GetAuiManager()
-
-        
         #dictionary of miodel {model class name, model class}
         self.model_list_box={}
@@ -64,4 +57,5 @@
     def onClosePage(self, event):
         """
+             close page and remove all references to the closed page
         """
         selected_page = self.GetPage(self.GetSelection())
@@ -78,12 +72,8 @@
                     break
             #Delete the page from notebook
-           
-            #print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name
-            
             if selected_page.name in self.fit_page_name:
                 self.fit_page_name.remove(selected_page.name)
                 
             if selected_page.name== self.draw_model_name:
-                #print "went here"
                 self.draw_model_name=None
                 self.model_page=None
@@ -91,18 +81,10 @@
                 self.model_page=None
                 self.draw_model_name=None
-            #selected_page.Destroy()
-            #self.RemovePage(page_number)
-            #i=self.DeletePage(page_number)
+            
         elif selected_page==self.about_page:
-            #selected_page.Destroy()
-            #self.DeletePage(page_number)
             self.about_page=None
         else:
-            
             self.manager.sim_page=None  
-            #self.DeletePage(page_number)
-   
-
-
+        
         
     def set_manager(self, manager):
@@ -112,5 +94,5 @@
         """
         self.manager = manager
-        #self.sim_page.set_manager(manager)
+
         
     def set_owner(self,owner):
@@ -119,7 +101,10 @@
             @param owner: the class responsible of plotting
         """
-        self.event_owner=owner
+        self.event_owner = owner
         
     def add_sim_page(self):
+        """
+            Add the simultaneous fit page
+        """
         from simfitpage import SimultaneousFitPage
         self.sim_page = SimultaneousFitPage(self, id=-1)
@@ -131,20 +116,17 @@
         """ 
             Add a fitting page on the notebook contained by fitpanel
-            @param panel: contains in the page to add
-            @param name: title of the page tab
+            @param data: data to fit
             @return panel : page just added for futher used. is used by fitting module
         """     
         try:
-            name = data.name # item in Data1D
+            name = data.name 
         except:
             name = 'Fit'
         
-        #if self.fit_page_name != name and self.draw_model_name !=name:
         if not name in self.fit_page_name :
-            #self.about_page.Disable()
             from fitpage1D import FitPage1D
             panel = FitPage1D(self,data, -1)
             panel.name=name
-            #m_name= "M"+str(self.count)  
+            
             panel.set_manager(self.manager)
             panel.set_owner(self.event_owner)
@@ -154,7 +136,7 @@
             self.fit_page_name.append(name)
     
-            return panel #,m_name
+            return panel 
         else:
-            return None #, None
+            return None 
         
     def _help_add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50):
@@ -167,5 +149,5 @@
         """
         from modelpage import ModelPage
-        #print "fitpanel model", model
+        
         panel = ModelPage(self,model,page_title, -1)
         panel.set_manager(self.manager)
@@ -201,14 +183,8 @@
             @param npts: number of Q points
         """
-        #print "self.draw_model_name none",self.draw_model_name
         if topmenu==True:
             if  self.draw_model_name ==None:
-                #print "self.draw_model_name none"
                 self._help_add_model_page(model,description,page_title, qmin=qmin, qmax=qmax, npts=npts)
             else:
-                #self.model_page.name=page_title
-                #self.draw_model_name=page_title
-                #print "wnent here self.draw_model_name ",self.draw_model_name,self.model_page.name,self.model_page
-                
                 self.model_page.select_model(model, page_title)
           
@@ -217,60 +193,7 @@
             @return the current page selected
         """
-        #return self.nb.GetCurrentPage()
         return self.GetPage(self.GetSelection() )
   
-    
-    def onClose(self, page=None,page_number=None):
-        """
-             close the current page except the simpage. remove each check box link to the model
-             selected on that page. remove its reference into page_finder (fitting module)
-        """
-        #print "model page", page_number, page, self.draw_model_name
-        if page!=None and page_number!=None:
-            i=self.DeletePage(page_number)
-            #self.nb.RemovePage(page_number)
-            #page.Destroy()
-            self.model_page_number=None
-            self.model_page=None
-            self.draw_model_name=None
-            #print"self.draw_model_name",self.draw_model_name
-            return 
-        try:
-            sim_page = self.GetPage(1)
-            selected_page = self.GetPage(self.GetSelection())
-            #print "sim_page ",sim_page ,selected_page
-            if sim_page != selected_page:
-                #print "sim_page ",sim_page ,selected_page
-                # remove the check box link to the model name of this page (selected_page)
-                sim_page.remove_model(selected_page)
-                #remove that page from page_finder of fitting module
-                page_finder=self.manager.get_page_finder() 
-                for page, value in page_finder.iteritems():
-                    if page==selected_page:
-                        del page_finder[page]
-                        break
-                #Delete the page from notebook
-                page_number = self.GetSelection()
-                #print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name
-                
-                if selected_page.name in self.fit_page_name:
-                    self.fit_page_name.remove(selected_page.name)
-                    
-                if selected_page.name== self.draw_model_name:
-                    #print "went here"
-                    self.draw_model_name=None
-                    self.model_page=None
-                if  page_number == 1:
-                    self.model_page=None
-                    self.draw_model_name=None
-                #selected_page.Destroy()
-                #self.RemovePage(page_number)
-                i=self.DeletePage(page_number)
-                #self.count =self.count -1 
-                
-        except:
-            raise
-        #print "fitpanel", self.draw_model_name 
-        
+   
     def set_model_list(self,dict):
          """ 
Index: sansview/perspectives/fitting/fitproblem.py
===================================================================
--- sansview/perspectives/fitting/fitproblem.py	(revision 2a8fac139d8cc1f41446e9eeb7178b18ec8186aa)
+++ sansview/perspectives/fitting/fitproblem.py	(revision 925a30e1970e2e81bed1969735af0a4824905734)
@@ -16,25 +16,33 @@
             and its name assign example [lineModel, M0]
         """
+        ## data used for fitting
         self.fit_data=None
-        self.theory_name=None
+        ## list containing couple of model and its name
         self.model_list=[]
+        ## if 1 this fit problem will be selected to fit , if 0 
+        ## it will not be selected for fit
         self.schedule=0
+        ##list containing parameter name and value
         self.list_param=[]
-        self.name_per_page=None
+        ## smear object to smear or not data1D
         self.smearer= None
+        ## same as fit_data but with more info for plotting
+        ## axis unit info and so on see plottables definition
         self.plotted_data=None
         
+        
     def set_smearer(self, smearer):
+        """
+          save reference of  smear object on fitdata
+          @param smear : smear object from DataLoader
+        """
         self.smearer= smearer
-        #print "smeaerer in fitproblem",self.smearer
+       
     def get_smearer(self):
+        """
+            return smear object
+        """
         return self.smearer
     
-    def save_model_name(self, name):  
-        self.name_per_page= name
-        
-        
-    def get_name(self):
-        return self.name_per_page
     
     def set_model(self,model,name):
@@ -53,4 +61,6 @@
         """
         self.plotted_data = data
+        
+        
     def add_fit_data(self,data):
         """ 
@@ -62,5 +72,4 @@
     def get_model(self):
         """ @return: saved model """
-        #print "fitproblem",self.model_list
         return self.model_list
      
@@ -89,20 +98,17 @@
     def set_model_param(self,name,value):
         """ 
-            set the value of a given parameter of this model
+            Store the name and value of a parameter of this fitproblem's model
             @param name: name of the given parameter
             @param value: value of that parameter
         """
-        #print "fitproblem",name,value
-        #self.model_list[0].setParam(name,value)
         self.list_param.append([name,value])
+        
+        
     def get_model_param(self):
         """ 
-            set the value of a given parameter of this model
-            @param name: name of the given parameter
-            @param value: value of that parameter
+            @return list of couple of parameter name and value
         """
-        #print self.param_name, self.param_value
-        #self.model_list[0].setParam(name,value)
         return self.list_param
+        
         
     def reset_model(self,model):
@@ -111,6 +117,6 @@
             @param value: new model
         """
-        #print "fitproblem : reset model"
         self.model_list[0]=model
+        
         
     def schedule_tofit(self, schedule=0):
@@ -123,4 +129,6 @@
         """ return true or false if a problem as being schedule for fitting"""
         return self.schedule
+    
+    
     def clear_model_param(self):
         """
@@ -128,2 +136,4 @@
         """
         self.list_param=[]
+        
+        
Index: sansview/perspectives/fitting/helpPanel.py
===================================================================
--- sansview/perspectives/fitting/helpPanel.py	(revision 2268d100cf4d0c2aa066591523a5c8846391f5d0)
+++ sansview/perspectives/fitting/helpPanel.py	(revision 925a30e1970e2e81bed1969735af0a4824905734)
@@ -46,10 +46,8 @@
         
         button_OK = wx.Button(self, wx.ID_OK, "OK")
-        #button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
-        
+
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
         sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        #sizer_button.Add(button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
+        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)       
         vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
 
@@ -63,5 +61,7 @@
     def __init__(self, parent, id, title):
         wx.Frame.__init__(self, parent, id, title, size=(600, 450))
-        
+        """
+             contains help info
+        """
         vbox1  = wx.BoxSizer(wx.HORIZONTAL)
         
@@ -127,7 +127,8 @@
         
         self.SetSizer(vbox1)
-        
         self.Centre()
         self.Show(True)
+        
+        
     def OnLinkClicked(self, event):
         """
Index: sansview/perspectives/fitting/old_ modelpage.py
===================================================================
--- sansview/perspectives/fitting/old_ modelpage.py	(revision ed2ea6affd15bc8ac6492c7f3afba6be6f2a899f)
+++ 	(revision )
@@ -1,1031 +1,0 @@
-import sys
-import wx
-import wx.lib
-import numpy
-import copy
-
-
-from sans.guicomm.events import StatusEvent   
-from sans.guiframe.utils import format_number
-(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
-_BOX_WIDTH = 80
-
-
-
-
-class ModelPage(wx.ScrolledWindow):
-    """
-        FitPanel class contains fields allowing to display results when
-        fitting  a model and one data
-        @note: For Fit to be performed the user should check at least one parameter
-        on fit Panel window.
-  
-    """
-    ## Internal name for the AUI manager
-    window_name = "Fit page"
-    ## Title to appear on top of the window
-    window_caption = "Fit Page"
-    name=""
-    def __init__(self, parent,model,name, *args, **kwargs):
-        wx.ScrolledWindow.__init__(self, parent, *args, **kwargs)
-        """ 
-            Initialization of the Panel
-        """
-        # model on which the fit would be performed
-        self.model=model
-        self.back_up_model= model.clone()
-        #list of dispersion paramaters
-        self.disp_list=[]
-        try:
-            self.disp_list=self.model.getDispParamList()
-        except:
-            pass 
-        self.manager = None
-        self.parent  = parent
-        self.event_owner = None
-        # this panel does contain data .existing data allow a different drawing
-        #on set_model parameters
-        self.data=None
-        #panel interface
-        self.vbox  = wx.BoxSizer(wx.VERTICAL)
-        self.sizer11 = wx.BoxSizer(wx.HORIZONTAL)
-        self.sizer10 = wx.GridBagSizer(5,5)
-        self.sizer9 = wx.GridBagSizer(5,5)
-        self.sizer8 = wx.GridBagSizer(5,5)
-        self.sizer7 = wx.GridBagSizer(5,5)
-        self.sizer6 = wx.GridBagSizer(5,5)
-        self.sizer5 = wx.GridBagSizer(5,5)
-        self.sizer4 = wx.GridBagSizer(5,5)
-       
-        #model selection
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(self.sizer4)
-        #model description
-        self.vbox.Add(self.sizer11)
-        #model paramaters layer
-        self.vbox.Add(self.sizer5)
-        #polydispersion selected
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(self.sizer6)
-        #combox box for type of dispersion
-        self.vbox.Add(self.sizer7)
-        #dispersion parameters layer
-        self.vbox.Add(self.sizer8)
-        # plotting range
-        self.vbox.Add(self.sizer9)
-        #close layer
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)
-        self.vbox.Add(self.sizer10)
-        
-      
-        #------------------ sizer 4  draw------------------------  
-       
-       
-        # define combox box
-        self.modelbox = wx.ComboBox(self, -1)
-         # preview selected model name
-        self.prevmodel_name=name
-        #print "model view prev_model",name
-        self.modelbox.SetValue(self.prevmodel_name)
-        #enable model 2D draw
-        self.enable2D= False
-        #filling sizer2
-        ix = 0
-        iy = 1
-        self.sizer4.Add(wx.StaticText(self,-1,'Model'),(iy,ix),(1,1)\
-                  , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        self.sizer4.Add(self.modelbox,(iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        id = wx.NewId()
-        self.model_view =wx.Button(self,id,'View 2D')
-        self.model_view.Bind(wx.EVT_BUTTON, self.onModel2D,id=id)
-        self.model_view.SetToolTipString("View model in 2D")
-        
-        self.sizer4.Add(self.model_view,(iy,ix),(1,1),\
-                   wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        
-        self.model_view.Enable()
-        self.model_view.SetFocus()
-        
-        ix = 0
-        iy += 1
-        self.sizer4.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-
-        #----------sizer6-------------------------------------------------
-        self.disable_disp = wx.RadioButton(self, -1, 'No', (10, 10), style=wx.RB_GROUP)
-        self.enable_disp = wx.RadioButton(self, -1, 'Yes', (10, 30))
-        self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.disable_disp.GetId())
-        self.Bind(wx.EVT_RADIOBUTTON, self.Set_DipersParam, id=self.enable_disp.GetId())
-        ix= 0
-        iy=1
-        self.sizer6.Add(wx.StaticText(self,-1,'Polydispersity: '),(iy,ix),(1,1)\
-                  , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        self.sizer6.Add(self.enable_disp ,(iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.sizer6.Add(self.disable_disp ,(iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix =0
-        iy+=1
-        self.sizer6.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)  
-
-        
-        #---------sizer 9 draw----------------------------------------
-       
-         ## Q range
-        self.qmin_x= 0.001
-        self.qmax_x= 0.1
-        self.num_points= 100
-        
-        
-        self.qmin    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))
-        self.qmin.SetValue(format_number(self.qmin_x))
-        self.qmin.SetToolTipString("Minimun value of Q in linear scale.")
-        self.qmin.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-        self.qmin.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)
-     
-        self.qmax    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))
-        self.qmax.SetValue(format_number(self.qmax_x))
-        self.qmax.SetToolTipString("Maximum value of Q in linear scale.")
-        self.qmax.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-        self.qmax.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)
-     
-
-        self.npts    = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20))
-        self.npts.SetValue(format_number(self.num_points))
-        self.npts.SetToolTipString("Number of point to plot.")
-        self.npts.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-        self.npts.Bind(wx.EVT_TEXT_ENTER, self._onparamEnter)
-       
-        ix = 0
-        iy = 1 
-        self.sizer9.Add(wx.StaticText(self, -1, 'Plotting Range'),(iy, ix),(1,1),\
-                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1 
-        self.sizer9.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.sizer9.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.sizer9.Add(wx.StaticText(self, -1, 'Npts'),(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix = 0
-        iy += 1
-        self.sizer9.Add(wx.StaticText(self, -1, 'Q range'),(iy, ix),(1,1),\
-                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix += 1
-        self.sizer9.Add(self.qmin,(iy, ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.sizer9.Add(self.qmax,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.sizer9.Add(self.npts,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        
-        ix =0
-        iy+=1 
-        self.sizer9.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        #----------sizer 10 draw------------------------------------------------------
-        id = wx.NewId()
-        self.btClose =wx.Button(self,id,'Close')
-        self.btClose.Bind(wx.EVT_BUTTON, self.onClose,id=id)
-        self.btClose.SetToolTipString("Close page.")
-        
-        ix= 3
-        iy= 1
-        self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        self.sizer10.Add( self.btClose,(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix =0
-        iy+=1
-        self.sizer10.Add((20,20),(iy,ix),(1,1),wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-       
-        # contains link between  model ,all its parameters, and panel organization
-        self.parameters=[]
-        self.fixed_param=[]
-        self.fittable_param=[]
-        self.polydisp= {}
-        #contains link between a model and selected parameters to fit 
-        self.param_toFit=[]
-        
-        #dictionary of model name and model class
-        self.model_list_box={}
-        #Draw initial panel
-         #-----sizer 11--------------------model description------
-        if self.model!=None:
-            self.set_panel(self.model)
-        self.theta_cb=None
-       
-       
-        self.vbox.Layout()
-        self.vbox.Fit(self) 
-        self.SetSizer(self.vbox)
-        self.SetScrollbars(20,20,55,40)
-        
-        self.Centre()
-        self.Layout()
-        self.parent.GetSizer().Layout()
-    def set_model_description(self, model):
-        
-        if model !=None and str(model.description)!=""and self.data==None:
-            self.sizer11.Clear(True)
-            self.box_description= wx.StaticBox(self, -1, 'Model Description')
-            boxsizer1 = wx.StaticBoxSizer(self.box_description, wx.VERTICAL)
-            boxsizer1.SetMinSize((320,20))
-            self.description = wx.StaticText(self,-1,str(model.description))
-            boxsizer1.Add(self.description, 0, wx.EXPAND)  
-            self.sizer11.Add(boxsizer1,1, wx.EXPAND | wx.ALL, 2)
-      
-        
-    def set_owner(self,owner):
-        """ 
-            set owner of fitpage
-            @param owner: the class responsible of plotting
-        """
-        self.event_owner=owner    
-   
-  
-    def set_manager(self, manager):
-        """
-             set panel manager
-             @param manager: instance of plugin fitting
-        """
-        self.manager = manager  
-        
-    def populate_box(self, dict):
-        """
-            Populate each combox box of each page
-            @param page: the page to populate
-        """
-        id=0
-        self.model_list_box=dict
-        list_name=[]
-        for item in  self.model_list_box.itervalues():
-            name = item.__name__
-            if hasattr(item, "name"):
-                name = item.name
-            list_name.append(name)
-        list_name.sort() 
-         
-        for name in list_name:
-            self.modelbox.Insert(name,int(id))
-            id+=1
-        wx.EVT_COMBOBOX(self.modelbox,-1, self._on_select_model) 
-        return 0
-    
-
-    def Set_DipersParam(self, event):
-        if self.enable_disp.GetValue():
-            if len(self.disp_list)==0:
-                ix=0
-                iy=1
-                self.fittable_param=[]
-                self.fixed_param=[]
-                self.sizer8.Clear(True)
-                model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model')
-                self.sizer7.Add(model_disp,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-                self.vbox.Layout()
-                self.SetScrollbars(20,20,55,40)
-                self.Layout()
-                self.parent.GetSizer().Layout()
-                return 
-            else:
-                if self.data !=None and self.model !=None: # allow to recognize data panel from model panel
-                    
-                
-                    self.cb1.SetValue(False)
-                    self.select_all_param_helper()
-                
-                self.populate_disp_box()
-                self.set_panel_dispers(self.disp_list)
-                
-        else:
-            if self.data !=None and self.model!=None:
-                if self.cb1.GetValue():
-                    self.select_all_param_helper()
-            try:
-                if self.back_up_model!=None:
-                    keys = self.back_up_model.getDispParamList()
-                    keys.sort()
-                    #disperse param into the initial state
-                    for item in keys:
-                        value= self.back_up_model.getParam(item)
-                        self.model.setParam(item, value)
-                    self._draw_model() 
-            except:
-                pass  
-                
-            self.fittable_param=[]        
-            self.fixed_param=[]
-            self.sizer7.Clear(True)
-            self.sizer8.Clear(True)
-            self.vbox.Layout()
-            self.SetScrollbars(20,20,55,40)
-            self.Layout()
-            self.parent.GetSizer().Layout()
-            
-    def populate_disp_box(self):
-        self.sizer7.Clear(True)
-        if len(self.disp_list)>0:
-            ix=0
-            iy=1
-            model_disp = wx.StaticText(self, -1, 'Model Disp')
-            self.sizer7.Add(model_disp,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1 
-            # set up the combox box
-            id = 0
-            import sans.models.dispersion_models 
-            self.polydisp= sans.models.dispersion_models.models
-            self.disp_box = wx.ComboBox(self, -1)
-            self.disp_box.SetValue("GaussianModel")
-            for k,v in self.polydisp.iteritems():
-                if str(v)=="MyModel":
-                    self.disp_box.Insert("Select customized Model",id)  
-                else:
-                    self.disp_box.Insert(str(v),id)  
-                id+=1
-            wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) 
-            self.sizer7.Add(self.disp_box,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            self.vbox.Layout()
-            self.SetScrollbars(20,20,55,40)
-            self.Layout()
-            self.parent.GetSizer().Layout()  
-            
-            
-    def set_range(self, qmin_x, qmax_x, npts):
-        """
-            Set the range for the plotted models
-            @param qmin: minimum Q
-            @param qmax: maximum Q
-            @param npts: number of Q bins
-        """
-        # Set the data members
-        self.qmin_x = qmin_x
-        self.qmax_x = qmax_x
-        self.num_points = npts
-        
-        # Set the controls
-        self.qmin.SetValue(format_number(self.qmin_x))
-        self.qmax.SetValue(format_number(self.qmax_x))
-        self.npts.SetValue(format_number(self.num_points))
-    def checkFitRange(self):
-        """
-            Check the validity of fitting range
-            @note: qmin should always be less than qmax or else each control box
-            background is colored in pink.
-        """
-       
-        flag = True
-        valueMin = self.qmin.GetValue()
-        valueMax = self.qmax.GetValue()
-        # Check for possible values entered
-        #print "fitpage: checkfitrange:",valueMin,valueMax
-        try:
-            if (float(valueMax)> float(valueMin)):
-                self.qmax.SetBackgroundColour(wx.WHITE)
-                self.qmin.SetBackgroundColour(wx.WHITE)
-            else:
-                flag = False
-                self.qmin.SetBackgroundColour("pink")
-                self.qmax.SetBackgroundColour("pink")      
-        except:
-            flag = False
-            self.qmin.SetBackgroundColour("pink")
-            self.qmax.SetBackgroundColour("pink")
-            
-        self.qmin.Refresh()
-        self.qmax.Refresh()
-        return flag
-    
-
-        
-    def onClose(self,event):
-        """ close the page associated with this panel"""
-        self.parent.onClose()
-        
-  
-        
-    def onModel2D(self, event):
-        """
-         call manager to plot model in 2D
-        """
-        # If the 2D display is not currently enabled, plot the model in 2D 
-        # and set the enable2D flag.
-        if self.enable2D==False:
-            self.enable2D=True
-            self._draw_model()
-            self.model_view.Disable()
-            
-    
-    def select_model(self, model, name):
-        """
-            Select a new model
-            @param model: model object 
-        """
-        self.model = model
-        self.parent.model_page.name = name
-        self.parent.draw_model_name = name
-        
-        print "select_model", self.name,model.__class__
-        self.set_panel(model)
-        self._draw_model(name)
-        
-        # Select the model from the combo box
-        items = self.modelbox.GetItems()
-        for i in range(len(items)):
-            print "model name",items[i],model.name, model.__class__.__name__
-            if items[i]==name:
-                self.modelbox.SetSelection(i)
-                
-                
-    def _on_select_Disp(self,event):
-        """
-             allow selecting different dispersion
-             self.disp_list should change type later .now only gaussian
-        """
-        type =event.GetString()
-        self.set_panel_dispers( self.disp_list,type )
-                
-    def _on_select_model(self,event):
-        """
-            react when a model is selected from page's combo box
-            post an event to its owner to draw an appropriate theory
-        """
-        self.disable_disp.SetValue(True)
-        self.sizer8.Clear(True)
-        self.sizer7.Clear(True)       
-        self.vbox.Layout()
-        self.SetScrollbars(20,20,55,40)
-        self.Layout()
-        self.parent.GetSizer().Layout()
-        for item in self.model_list_box.itervalues():
-            name = item.__name__
-            if hasattr(item, "name"):
-                name = item.name
-            if name ==event.GetString():
-                model=item()
-                self.model= model
-                self.set_panel(model)
-                self.name= name
-                self.model_view.SetFocus()
-                self.parent.model_page.name=name
-                self.parent.draw_model_name=name
-                #self.manager.draw_model(model, name)
-                #self.enable2D=False
-                #self.model_view.Enable()
-                self._draw_model(name)
-            
-            
-    def get_model_box(self): 
-        """ return reference to combox box self.model"""
-        return self.modelbox
-
-    
-    def get_param_list(self):
-        """
-            @return self.param_toFit: list containing  references to TextCtrl
-            checked.Theses TextCtrl will allow reference to parameters to fit.
-            @raise: if return an empty list of parameter fit will nnote work 
-            properly so raise ValueError,"missing parameter to fit"
-        """
-        if self.param_toFit !=[]:
-            return self.param_toFit
-        else:
-            raise ValueError,"missing parameter to fit"
-        
-        
-    def set_panel(self,model):
-        """
-            Build the panel from the model content
-            @param model: the model selected in combo box for fitting purpose
-        """
-        print "set_panel", model
-        
-        self.sizer5.Clear(True)
-        self.parameters = []
-        self.param_toFit=[]
-        self.fixed_param=[]
-        self.model = model
-        
-        self.set_model_description( self.model) 
-        
-        keys = self.model.getParamList()
-        #list of dispersion paramaters
-        self.disp_list=self.model.getDispParamList()
-       
-        keys.sort()
-        ik=0
-        im=1
-        
-        iy = 1
-        ix = 0
-        self.cb1 = wx.CheckBox(self, -1,"Select all", (10, 10))
-        if self.data!=None:
-            wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param)
-            self.cb1.SetValue(False)
-        else:
-            self.cb1.Disable()
-            self.cb1.Hide()
-       
-        self.sizer5.Add(self.cb1,(iy, ix),(1,1),\
-                          wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        ix +=1
-        self.text2_2 = wx.StaticText(self, -1, 'Values')
-        self.sizer5.Add(self.text2_2,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=2
-        self.text2_3 = wx.StaticText(self, -1, 'Errors')
-        self.sizer5.Add(self.text2_3,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        self.text2_3.Hide() 
-        ix +=1
-        self.text2_4 = wx.StaticText(self, -1, 'Units')
-        self.sizer5.Add(self.text2_4,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        self.text2_4.Hide()
-        disp_list=self.model.getDispParamList()
-        for item in keys:
-            if not item in disp_list:
-                iy += 1
-                ix = 0
-    
-                cb = wx.CheckBox(self, -1, item, (10, 10))
-                if self.data!=None:
-                    cb.SetValue(False)
-                    wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param)
-                else:
-                    cb.Disable()
-                self.sizer5.Add( cb,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-               
-                ix += 1
-                value= self.model.getParam(item)
-                ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                ctl1.SetValue(str (format_number(value)))
-                ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-                ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
-                self.sizer5.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                
-                ix += 1
-                text2=wx.StaticText(self, -1, '+/-')
-                self.sizer5.Add(text2,(iy, ix),(1,1),\
-                                wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-                text2.Hide()  
-                ix += 1
-                ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                self.sizer5.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                ctl2.Hide()
-                ix +=1
-                # Units
-                try:
-                    units = wx.StaticText(self, -1, self.model.details[item][0], style=wx.ALIGN_LEFT)
-                except:
-                    units = wx.StaticText(self, -1, "", style=wx.ALIGN_LEFT)
-                self.sizer5.Add(units, (iy,ix),(1,1),  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-           
-            self.parameters.append([cb,ctl1,text2,ctl2])
-                
-        iy+=1
-        self.sizer5.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        
-        #Display units text on panel
-        for item in keys:   
-            if self.model.details[item][0]!='':
-                self.text2_4.Show()
-                break
-            else:
-                self.text2_4.Hide()
-        #Disable or enable fit button
-        """
-        if not (len(self.param_toFit ) >0):
-            self.qmin.Disable()
-            self.qmax.Disable()
-        else:
-            self.qmin.Enable()
-            self.qmax.Enable()
-        """  
-        self.vbox.Layout()
-        self.SetScrollbars(20,20,55,40)
-        self.Layout()
-        self.parent.GetSizer().Layout()
-    def _selectDlg(self):
-        import os
-        dlg = wx.FileDialog(self, "Choose a weight file", os.getcwd(), "", "*.*", wx.OPEN)
-        path = None
-        if dlg.ShowModal() == wx.ID_OK:
-            path = dlg.GetPath()
-        dlg.Destroy()
-        return path
-    def read_file(self, path):
-        try:
-            if path==None:
-                wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Selected Distribution was not loaded: %s"%path))
-                return None, None
-            input_f = open(path, 'r')
-            buff = input_f.read()
-            lines = buff.split('\n')
-            
-            angles = []
-            weights=[]
-            for line in lines:
-                toks = line.split()
-                if len(toks)==2:
-                    try:
-                        angle = float(toks[0])
-                        weight = float(toks[1])
-                    except:
-                        # Skip non-data lines
-                        pass
-                    angles.append(angle)
-                    weights.append(weight)
-            return numpy.array(angles), numpy.array(weights)
-        except:
-            raise 
-        
-    def _draw_disp_theta(self): 
-        path = self._selectDlg()
-        dispersion=None
-       
-        for key, value in self.polydisp.iteritems():
-            if value =="MyModel":
-                disp_ph = key()
-                disp_th = key()
-                break
-        values,weights = self.read_file(path)
-        if values ==None and weights==None:
-            return 
-        import math
-        disp_ph.set_weights( values, weights)
-        disp_th.set_weights( values, weights)
-        
-        if self.theta_cb !=None:
-            angle= self.theta_cb.GetLabelText()
-        n=0
-        self.disp_list=self.model.getDispParamList()
-        if angle.lower().count("theta")>0:   
-            for param in self.model.getParamList():
-                if  not param in self.disp_list and  param.lower().count("theta")>0: 
-                    self.model.set_dispersion(param, disp_th)
-                    self.model.dispersion[param]['npts'] = len(values)
-                    n+=1
-           
-            if n ==0:
-              wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Model contains no theta distribution"))  
-            else:
-                self._draw_model() 
-    def _draw_disp_Phi(self): 
-        path = self._selectDlg()
-        dispersion=None
-       
-        for key, value in self.polydisp.iteritems():
-            if value =="MyModel":
-                disp_ph = key()
-                disp_th = key()
-                break
-        values,weights = self.read_file(path)
-        if values ==None and weights==None:
-            return 
-        import math
-        disp_ph.set_weights( values, weights)
-        disp_th.set_weights( values, weights)
-        
-        if self.theta_cb !=None:
-            angle= self.theta_cb.GetLabelText()
-        n=0
-        self.disp_list=self.model.getDispParamList()
-        if angle.lower().count("theta")>0:   
-            for param in self.model.getParamList():
-                if  not param in self.disp_list and  param.lower().count("theta")>0: 
-                    self.model.set_dispersion(param, disp_th)
-                    self.model.dispersion[param]['npts'] = len(values)
-                    n+=1
-           
-            if n ==0:
-              wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Model contains no theta distribution"))  
-            else:
-                self._draw_model() 
-          
-          
-    def select_disp_angle(self, event): 
-        if not self.phi_cb.GetValue():
-            return
-        path = self._selectDlg()
-        dispersion=None
-       
-        for key, value in self.polydisp.iteritems():
-            if value =="MyModel":
-                disp_ph = key()
-                disp_th = key()
-               
-                break
-        try:
-            values,weights = self.read_file(path)
-        except:
-            raise
-        #print "values,weights",values,weights
-        if values ==None and weights==None:
-            return 
-        import math
-        wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Costumized Distribution: %s"% path))
-       
-        disp_ph.set_weights( values, weights)
-        disp_th.set_weights( values, weights)
-        
-       
-        
-        if self.theta_cb !=None:
-            angle= self.phi_cb.GetLabelText()
-        n=0
-        print "hello1",self.model.runXY([0.01,0.01]) 
-        self.disp_list=self.model.getDispParamList()
-        name= "phi"
-        if angle.lower().count(name)>0:   
-            for param in self.model.getParamList():
-                if  not param in self.disp_list and  param.lower().count(name)>0: 
-                    self.model.set_dispersion(param, disp_th)
-                    print "para, th",param, disp_th
-                    #self.model.dispersion[param]['npts'] = len(values)
-                    n+=1
-            print "model dispers list",self.model.getDispParamList()
-            if n ==0:
-              wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Model contains no %s distribution"%name))  
-            else:
-                print "hello2",self.model.runXY([0.01,0.01]) 
-                #self._draw_model()
-                qmin=self.qmin_x
-                qmax=self.qmax_x
-                qstep= self.num_points
-                x=  numpy.linspace(start= -1*qmax,
-                               stop= qmax,
-                               num= qstep,
-                               endpoint=True )  
-                y = numpy.linspace(start= -1*qmax,
-                               stop= qmax,
-                               num= qstep,
-                               endpoint=True )
-                output= numpy.zeros([len(x),len(y)])
-                for i_x in range(int(len(x))):
-                    for i_y in range(int(len(y))):
-                        if (x[i_x]*x[i_x]+y[i_y]*y[i_y]) \
-                        < qmin * qmin:
-                            output[i_x] [i_y]=0   
-                        else:
-                            value = self.model.runXY([x[i_x], y[i_y]])
-                            output[i_x] [i_y]=value 
-                print"modelpage", output
-                self.manager.complete( output=output, elapsed=None, model=self.model, qmin=qmin, qmax=qmax,qstep=qstep)
-                #self._draw_model()
-                      
-                      
-                      
-    def set_panel_dispers(self, disp_list, type="GaussianModel" ):
-        
-        self.fittable_param=[]
-        self.fixed_param=[]
-        
-        ix=0
-        iy=1
-                ### this will become a separate method
-        if type== "Select customized Model":
-            ix=0
-            iy=1
-            self.sizer8.Clear(True)        
-            disp1 = wx.StaticText(self, -1, 'Array Dispersion')
-            self.sizer8.Add(disp1,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            
-            ix+=1 
-            self.theta_cb = wx.CheckBox(self, -1,"Theta ", (10, 10))
-            wx.EVT_CHECKBOX(self, self.theta_cb.GetId(), self.select_disp_angle)
-            self.sizer8.Add(self.theta_cb,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix+=1
-            self.phi_cb = wx.CheckBox(self, -1,"Phi", (10, 10))
-            wx.EVT_CHECKBOX(self, self.phi_cb.GetId(), self.select_disp_angle)
-            self.sizer8.Add(self.phi_cb,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            
-            ix =0
-            iy +=1 
-            self.sizer8.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)        
-            self.vbox.Layout()
-            self.SetScrollbars(20,20,55,40)
-            self.Layout()
-            self.parent.GetSizer().Layout()  
-           
-        if type== "GaussianModel" :
-
-            self.sizer8.Clear(True)
-            disp = wx.StaticText(self, -1, 'Dispersion')
-            self.sizer8.Add(disp,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-            ix += 1 
-            values = wx.StaticText(self, -1, 'Values')
-            self.sizer8.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix +=2
-            self.text2_3 = wx.StaticText(self, -1, 'Errors')
-            self.sizer8.Add(self.text2_3,(iy, ix),(1,1),\
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            self.text2_3.Hide() 
-           
-            ix += 1 
-            npts = wx.StaticText(self, -1, 'Npts')
-            self.sizer8.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            ix += 1 
-            nsigmas = wx.StaticText(self, -1, 'Nsigmas')
-            self.sizer8.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-            
-            disp_list.sort()
-            print disp_list,self.model.dispersion
-            for item in self.model.dispersion.keys():
-                name1=item+".width"
-                name2=item+".npts"
-                name3=item+".nsigmas"
-                iy += 1
-                for p in self.model.dispersion[item].keys():
-                    #print "name 1 2 3", name1, name2, name3
-                    if p=="width":
-                        ix = 0
-                        cb = wx.CheckBox(self, -1, name1, (10, 10))
-                        if self.data !=None:
-                            cb.SetValue(False)
-                            wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param)
-                        else:
-                            cb.Disable()
-                        self.sizer8.Add( cb,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-                        ix = 1
-                        value= self.model.getParam(name1)
-                        ctl1 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                        ctl1.SetValue(str (format_number(value)))
-                        ctl1.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-                        ctl1.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
-                        self.sizer8.Add(ctl1, (iy,ix),(1,1), wx.EXPAND)
-                        
-                        ix = 2
-                        text2=wx.StaticText(self, -1, '+/-')
-                        self.sizer8.Add(text2,(iy, ix),(1,1),\
-                                        wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-                        text2.Hide()  
-                        ix = 3
-                        ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                        self.sizer8.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                        ctl2.Hide()
-                        self.fittable_param.append([cb,ctl1,text2,ctl2])
-                       
-                        
-                    elif p=="npts":
-                            ix =4 
-                            value= self.model.getParam(name2)
-                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER)
-                            Tctl.SetValue(str (format_number(value)))
-                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
-                            self.sizer8.Add(Tctl, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([name2, Tctl])
-                    elif p=="nsigmas":
-                            ix =5 
-                            value= self.model.getParam(name3)
-                            Tctl = wx.TextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER)
-                            Tctl.SetValue(str (format_number(value)))
-                            Tctl.Bind(wx.EVT_KILL_FOCUS, self._onparamEnter)
-                            Tctl.Bind(wx.EVT_TEXT_ENTER,self._onparamEnter)
-                            self.sizer8.Add(Tctl, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                            self.fixed_param.append([name3, Tctl])
-                wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Selected Distribution: Gaussian"))   
-            ix =0
-            iy +=1 
-            self.sizer8.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)        
-            self.vbox.Layout()
-            self.SetScrollbars(20,20,55,40)
-            self.Layout()
-            self.parent.GetSizer().Layout()  
-          
-         
-           
-        
-    def _onparamEnter(self,event):
-        """ 
-            when enter value on panel redraw model according to changed
-        """
-        self.set_model_parameter()
-        
-    def set_model_parameter(self):
-        if len(self.parameters) !=0 and self.model !=None:
-            # Flag to register when a parameter has changed.
-            is_modified = False
-            for item in self.fittable_param:
-                try:
-                     name=str(item[0].GetLabelText())
-                     value= float(item[1].GetValue())
-                     #print "model para", name,value
-                     # If the value of the parameter has changed,
-                     # update the model and set the is_modified flag
-                     if value != self.model.getParam(name):
-                         #print "went hereee"
-                         self.model.setParam(name,value)
-                         
-                         is_modified = True
-                         
-                except:
-                    raise
-                    wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
-                
-            for item in self.fixed_param:
-                try:
-                     name=str(item[0])
-                     value= float(item[1].GetValue())
-                     #print "model para", name,value,self.model.getParam(name)
-                     # If the value of the parameter has changed,
-                     # update the model and set the is_modified flag
-                     if value != self.model.getParam(name):
-                         #print "went hereee"
-                         self.model.setParam(name,value)
-                         is_modified = True
-                         
-                except:
-                    raise
-                    wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
-                
-            for item in self.parameters:
-                try:
-                     name=str(item[0].GetLabelText())
-                     value= float(item[1].GetValue())
-                     #print " fittable model para", name,value
-                     # If the value of the parameter has changed,
-                     # update the model and set the is_modified flag
-                     if value != self.model.getParam(name):
-                         #print "went here", name,value
-                         self.model.setParam(name,value)
-                         is_modified = True
-                except:
-                     wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            "Model Drawing  Error:wrong value entered : %s"% sys.exc_value))
-            
-            # Here we should check whether the boundaries have been modified.
-            # If qmin and qmax have been modified, update qmin and qmax and 
-            # set the is_modified flag to True
-            if float(self.qmin.GetValue()) != self.qmin_x:
-                self.qmin_x = float(self.qmin.GetValue())
-                is_modified = True
-            if float(self.qmax.GetValue()) != self.qmax_x:
-                self.qmax_x = float(self.qmax.GetValue())
-                is_modified = True
-            
-            if float(self.npts.GetValue()) !=  self.num_points:
-                self.num_points = float(self.npts.GetValue())
-                is_modified = True
-          
-            if is_modified:
-                self._draw_model()            
-            
-    def _draw_model(self, name=None):
-        """
-            Method to draw or refresh a plotted model.
-            The method will use the data member from the model page
-            to build a call to the fitting perspective manager.
-            
-            [Note to coder: This way future changes will be done in only one place.] 
-        """
-        #print "_draw_model",self.model
-        if name==None:
-            name= self.model.name
-       
-        self.manager.draw_model(self.model, name, data=self.data,
-                                qmin=self.qmin_x, qmax=self.qmax_x,
-                                qstep= self.num_points,
-                                enable2D=self.enable2D)
-       
-    def select_param(self,event):
-        pass
-    def select_all_param(self,event): 
-        pass
-    def select_all_param_helper(self):
-        """
-             Allows selecting or delecting button
-        """
-        self.param_toFit=[]
-        if  self.parameters !=[]:
-            if  self.cb1.GetValue()==True:
-                for item in self.parameters:
-                    item[0].SetValue(True)
-                    list= [item[0],item[1],item[2],item[3]]
-                    self.param_toFit.append(list )
-                if len(self.fittable_param)>0:
-                    for item in self.fittable_param:
-                        item[0].SetValue(True)
-                        list= [item[0],item[1],item[2],item[3]]
-                        self.param_toFit.append(list )
-            else:
-                for item in self.parameters:
-                    item[0].SetValue(False)
-                for item in self.fittable_param:
-                    item[0].SetValue(False)
-                self.param_toFit=[]
-               
-                
-       
Index: sansview/perspectives/fitting/old_fitpanel.py
===================================================================
--- sansview/perspectives/fitting/old_fitpanel.py	(revision 2a8fac139d8cc1f41446e9eeb7178b18ec8186aa)
+++ 	(revision )
@@ -1,240 +1,0 @@
-import wx
-import wx.aui
-import wx.lib
-import numpy
-import string ,re
-#import models
-_BOX_WIDTH = 80
-
-(FitPageEvent, EVT_FIT_PAGE)   = wx.lib.newevent.NewEvent()
-class FitPanel(wx.aui.AuiNotebook):    
-#class FitPanel(wx.aui.AuiNotebook,wx.panel):
-    """
-        FitPanel class contains fields allowing to fit  models and  data
-        @note: For Fit to be performed the user should check at least one parameter
-        on fit Panel window.
-       
-    """
-    ## Internal name for the AUI manager
-    window_name = "Fit panel"
-    ## Title to appear on top of the window
-    window_caption = "Fit Panel "
-    CENTER_PANE = True
-    def __init__(self, parent, *args, **kwargs):
-        
-        wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_SCROLL_BUTTONS )
-        #wx.aui.AuiNotebook.__init__(self,parent,-1, style=wx.aui.AUI_NB_DEFAULT_STYLE  )
-        
-        
-        self.manager=None
-        self.parent=parent
-        self.event_owner=None
-        
-        pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE
-        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.onClosePage)
-        #Creating the default page --welcomed page
-        from sans.guiframe.welcome_panel import PanelAbout
-        self.about_page = PanelAbout(self, -1)
-        self.AddPage(self.about_page,"welcome!")
-        #self.about_page.Disable()
-        #Creating a page for simultaneous fitting
-        from simfitpage import SimultaneousFitPage
-        self.sim_page = SimultaneousFitPage(self, id=-1)
-        self.AddPage(self.sim_page,"Simultaneous Fit")
-        
-        self._mgr = wx.aui.AuiManager(self)
-
-        
-        #dictionary of miodel {model class name, model class}
-        self.model_list_box={}
-        # save the title of the last page tab added
-        self.fit_page_name=None
-        self.draw_model_name=None
-        #model page info
-        self.model_page_number=None
-       
-        self.model_page=None
-        # increment number for model name
-        self.count=0
-        #updating the panel
-        self.Update()
-        self.Center()
-    def onClosePage(self, event):
-        self.ToggleWindowStyle(wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
-        #print "went here",self.get_current_page(), self.GetPage(0)
-        #event.Skip()
-        if self.GetPageCount() <= 2:
-            #print "wente here"
-            
-            # Prevent last tab from being closed
-            self.ToggleWindowStyle(~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB)
-            
-
-   
-
-
-        
-    def set_manager(self, manager):
-        """
-             set panel manager
-             @param manager: instance of plugin fitting
-        """
-        self.manager = manager
-        self.sim_page.set_manager(manager)
-        
-    def set_owner(self,owner):
-        """ 
-            set and owner for fitpanel
-            @param owner: the class responsible of plotting
-        """
-        self.event_owner=owner
-      
-        
-    def add_fit_page( self,data ):
-        """ 
-            Add a fitting page on the notebook contained by fitpanel
-            @param panel: contains in the page to add
-            @param name: title of the page tab
-            @return panel : page just added for futher used. is used by fitting module
-        """     
-        try:
-            name = data.name # item in Data1D
-        except:
-            name = 'Fit'
-        
-        if self.fit_page_name != name:
-            #self.about_page.Disable()
-            from fitpage1D import FitPage1D
-            panel = FitPage1D(self,data, -1)
-            panel.name=name
-            #m_name= "M"+str(self.count)  
-            panel.set_manager(self.manager)
-            panel.set_owner(self.event_owner)
-            
-            self.AddPage(page=panel,caption=name,select=True)
-            panel.populate_box( self.model_list_box)
-            self.fit_page_name = name
-            EVT_FIT_PAGE
-            return panel #,m_name
-        else:
-            return None #, None
-        
-    def _help_add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50):
-        """
-            #TODO: fill in description
-            
-            @param qmin: mimimum Q
-            @param qmax: maximum Q
-            @param npts: number of Q points
-        """
-        from modelpage import ModelPage
-        #print "fitpanel model", model
-        panel = ModelPage(self,model,page_title, -1)
-        panel.set_manager(self.manager)
-        panel.set_owner(self.event_owner)
-        self.AddPage(page=panel,caption="Model",select=True)
-        panel.populate_box( self.model_list_box)
-        panel.name = page_title
-        self.draw_model_name=page_title
-        self.model_page_number=self.GetSelection()
-        self.model_page=self.GetPage(self.GetSelection())
-        
-        
-        # Set the range used to plot models
-        self.model_page.set_range(qmin, qmax, npts)
-        
-        # We just created a model page, we are ready to plot the model
-        #self.manager.draw_model(model, model.name)
-        #FOR PLUGIN  for somereason model.name is = BASEcomponent
-        self.manager.draw_model(model, page_title)
-        
-        
-    def add_model_page(self,model,description,page_title, qmin=0, qmax=0.1, npts=50, topmenu=False):
-        """
-            Add a model page only one  to display any model selected from the menu or the page combo box.
-            when this page is closed than the user will be able to open a new one
-            
-            @param model: the model for which paramters will be changed
-            @param page_title: the name of the page
-            @param description: [Coder: fill your description!]
-            @param page_title: [Coder: fill your description!]
-            @param qmin: mimimum Q
-            @param qmax: maximum Q
-            @param npts: number of Q points
-        """
-        print "self.draw_model_name none",self.draw_model_name
-        if topmenu==True:
-            if  self.draw_model_name ==None:
-                print "self.draw_model_name none"
-                self._help_add_model_page(model,description,page_title, qmin=qmin, qmax=qmax, npts=npts)
-            else:
-                #self.model_page.name=page_title
-                #self.draw_model_name=page_title
-                #print "wnent here self.draw_model_name ",self.draw_model_name,self.model_page.name,self.model_page
-                
-                self.model_page.select_model(model, page_title)
-          
-    def get_current_page(self):
-        """
-            @return the current page selected
-        """
-        #return self.nb.GetCurrentPage()
-        return self.GetPage(self.GetSelection() )
-  
-    
-    def onClose(self, page=None,page_number=None):
-        """
-             close the current page except the simpage. remove each check box link to the model
-             selected on that page. remove its reference into page_finder (fitting module)
-        """
-        print "model page", page_number, page, self.draw_model_name
-        if page!=None and page_number!=None:
-            i=self.DeletePage(page_number)
-            #self.nb.RemovePage(page_number)
-            #page.Destroy()
-            self.model_page_number=None
-            self.model_page=None
-            self.draw_model_name=None
-            print"self.draw_model_name",self.draw_model_name
-            return 
-        try:
-            sim_page = self.GetPage(1)
-            selected_page = self.GetPage(self.GetSelection())
-            print "sim_page ",sim_page ,selected_page
-            if sim_page != selected_page:
-                print "sim_page ",sim_page ,selected_page
-                # remove the check box link to the model name of this page (selected_page)
-                sim_page.remove_model(selected_page)
-                #remove that page from page_finder of fitting module
-                page_finder=self.manager.get_page_finder() 
-                for page, value in page_finder.iteritems():
-                    if page==selected_page:
-                        del page_finder[page]
-                        break
-                #Delete the page from notebook
-                page_number = self.GetSelection()
-                print "on close",selected_page.name,self.GetPageText(page_number),self.draw_model_name
-                if selected_page.name== self.draw_model_name:
-                    print "went here"
-                    self.draw_model_name=None
-                    self.model_page=None
-                if  page_number == 1:
-                    self.model_page=None
-                    self.draw_model_name=None
-                #selected_page.Destroy()
-                #self.RemovePage(page_number)
-                i=self.DeletePage(page_number)
-                #self.count =self.count -1 
-                self.fit_page_name=None
-        except:
-            raise
-        #print "fitpanel", self.draw_model_name 
-        
-    def set_model_list(self,dict):
-         """ 
-             copy a dictionary of model into its own dictionary
-             @param dict: dictionnary made of model name as key and model class
-             as value
-         """
-         self.model_list_box = dict
-  
Index: sansview/perspectives/fitting/simfitpage.py
===================================================================
--- sansview/perspectives/fitting/simfitpage.py	(revision ed2ea6affd15bc8ac6492c7f3afba6be6f2a899f)
+++ sansview/perspectives/fitting/simfitpage.py	(revision 925a30e1970e2e81bed1969735af0a4824905734)
@@ -9,5 +9,5 @@
         two data members window_name and window_caption
     """
-      ## Internal name for the AUI manager
+    ## Internal name for the AUI manager
     window_name = "simultaneous Fit page"
     ## Title to appear on top of the window
@@ -21,9 +21,7 @@
         """
         self.parent = parent
-        #self.page_finder = page_finder
         self.page_finder={}
         self.sizer3 = wx.GridBagSizer(5,5)
         self.sizer1 = wx.GridBagSizer(5,5)
-        #self.sizer2 = wx.GridBagSizer(5,5)
         self.sizer2  = wx.BoxSizer(wx.HORIZONTAL)
         self.vbox  = wx.BoxSizer(wx.VERTICAL)
@@ -54,5 +52,4 @@
         self.model_toFit=[]
         
-        #self.add_model(self.page_finder)
         self.vbox.Layout()
         self.vbox.Fit(self) 
@@ -84,4 +81,5 @@
         self.add_model( self.manager.page_finder)
         
+        
     def select_all_model_name(self,event):
         """
@@ -92,10 +90,7 @@
             for item in self.model_list:
                 item[0].SetValue(True)
-                #item[1].schedule_tofit(1)
                 self.manager.schedule_for_fit( value=1,fitproblem =item[1]) 
                 self.model_toFit.append(item)
         else:
-            #print"simfit: deselected all"
-            
             for item in self.model_list:
                 item[0].SetValue(False) 
@@ -112,5 +107,4 @@
         if len(self.model_list)>0:
             for item in self.model_list:
-                #print "went here to clear"
                 item[0].SetValue(False) 
                 self.manager.schedule_for_fit( value=0,fitproblem =item[1])
@@ -123,5 +117,4 @@
         iy = 1 
         list=[]
-       # if len(self.page_finder)>0:
         for page, value in page_finder.iteritems():
             try:
@@ -137,6 +130,4 @@
                 self.model_list.append([cb,value,page,modelname])
             except:
-                #wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Simultaneous fit: %s doesn't have a model selected yet %s" % \
-                #(value.get_data().group_id,sys.exc_value)))
                 pass
         iy +=1
@@ -145,4 +136,5 @@
         self.vbox.Layout()
         
+        
     def remove_model(self,delpage):
         """
@@ -150,6 +142,4 @@
              @param delpage: the page removed
         """
-        #print "self.model_list",self.model_list
-       
         self.model_list=[]
         self.model_toFit=[]
@@ -174,6 +164,4 @@
                     self.model_list.append([cb,value,page,modelname])
             except:
-                #wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Simultaneous fit: %s doesn't have a model selected yet %s" % \
-                #(value.get_data().group_id,sys.exc_value)))
                 pass
         iy +=1
@@ -182,4 +170,5 @@
         self.vbox.Layout()
         
+        
     def select_model_name(self,event):
         """
@@ -189,10 +178,7 @@
         for item in self.model_list:
             if item[0].GetValue()==True:
-                #item[1].schedule_tofit('True')
-                #item[1].schedule_tofit(1)
                 self.model_toFit.append(item)
                 self.manager.schedule_for_fit( value=1,fitproblem =item[1]) 
             else:
-                #print"simfit: deselected one"
                 self.manager.schedule_for_fit( value=0,fitproblem =item[1]) 
                 if item in self.model_toFit:
@@ -209,15 +195,13 @@
     def set_model(self):
         """
-            set_model take values in self.params which are the values enters by the user
-            and try to assign them into the model concerned in self.manager. page.finder
+            set_model take values in self.params which are the values
+            entered by the user and try to assign them into the model 
+            concerned in self.manager. page.finder
         """
         if len(self.params) >0:
             for item in self.model_toFit:
-                #print"simfitpage: self.model_toFit",item[1]
                 list=item[1].get_model()
-                #print "simfitpage: list fitpanel2",list,list[0]
                 model=list[0]
                 param_list=model.getParamList()
-                #print "simfitpage: on set_model self.params ",self.params
                 if self.params !=[]:
                     for element in self.params:
@@ -225,10 +209,7 @@
                             for item in param_list:
                                 if item==str(element[1]):
-                                    #print "simfitpage: on set_model page 1",param_list
-                                    #print "simfitpage: model name",element[0], model.name
-                                    #print "simfitpage: param name ,param value",element[1],element[2]
-                                    self.manager.set_page_finder(model.name,element[1],\
+                                    self.manager.set_page_finder(model.name,element[1],
                                                                  str(element[2]))
-                            #print "simfitpage:on set_model page 2",model.params['A'],self.params[2]
+                           
     
     def _onTextEnter(self):
@@ -236,16 +217,14 @@
             get values from the constrainst textcrtl ,parses them into model name
             parameter name and parameters values.
-            store them in a list self.params .when when params is not empty set_model uses it
-            to reset the appropriate model and its appropriates parameters
+            store them in a list self.params .when when params is not empty set_model 
+            uses it to reset the appropriate model and its appropriates parameters
         """
         value= self.ctl2.GetValue()
         if value:
             self.params=[]
-            #print "simfitpage: value",value
             try:
                 expression='[\s,;]'
                 if re.search(expression,value) !=None:
                     word=re.split(expression,value)
-                    #print "simfitpage: when herre",word
                     for item in word:
                         self.params.append(self.parser_helper(item))
@@ -253,84 +232,28 @@
                     self.params.append(self.parser_helper(value))  
             except:
-                #raise
                 wx.PostEvent(self.parent.Parent, StatusEvent(status="Constraint Error: %s" % sys.exc_value))
-        #print "simfitpage: self.params",self.params
-    def new_parser_helper(self,value):
+      
+        
+    def parser_helper(self,value):
         """
              @return  param:a list containing the name of a model ,its parameters 
              value and name extracted from the constrainst controlbox
         """
-        from sans.guiframe import utils
-        mylist=["=","<",">","<=", ">="]
-        for item in mylist:
-            if utils.look_for_tag( value,str(item))[0]:
-                #print "went here"
-                model_param = utils.split_text(str(item), value,1)
-                param_name = model_param[0]
-                param_value = model_param[1]
-                #print "simpage",utils.look_for_tag(param_name,"\.")[0]
-                if utils.look_for_tag(param_name,"\.")[0]:
-                    param_names = utils.split_text("\.",param_name,1)
-                    model_name = param_names[0]
-                    param_name = param_names[1]
-                    ##### just added
-                    #print "simfitpage: param name",model_name,param_name
-                
-                    param=[str(model_name),param_name,str(param_value),"="]
-                    #print "simfitpage: param",param
-                    return param
-                else:
-                    #raise ValueError,"cannot evaluate this expression"
-                    wx.PostEvent(self.parent.Parent,
-                                  StatusEvent(status="cannot evaluate this expression"))
-                    return
-            elif utils.look_for_tag( value,"<")[0]:
-                model_param = utils.split_text("<", value,2)
-                if len(model_param)== 2:
-                    try:
-                        param_name = str(model_param[0])
-                        param_value = float(model_param[1])
-                        param=[str(model_name),param_name,param_value,"<"]
-                        #print "simfitpage: param",param
-                        return param
-                    except:
-                        wx.PostEvent(self.parent.Parent, StatusEvent(status="\
-                        could read this expression%s" % sys.exc_value))
-                        return
-            else:
-                #raise ValueError,"Missing '=' in expression"
-                wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression"))
-               
-            
-        
-    def parser_helper(self,value):
-        """
-             @return  param:a list containing the name of a model ,its parameters 
-             value and name extracted from the constrainst controlbox
-        """
-        #print "simfitpage: value",value
         if string.find(value, "=") !=-1:
             model_param= re.split("=",value)
             param_name=model_param[0]
             param_value=model_param[1]
-            #print"simfitpage: ", param_name
-            #print "simfitpage: ",param_value
+            
             if string.find(param_name,".")!=-1:
                 param_names= re.split("\.",param_name)
                 model_name=param_names[0]
                 param_name=param_names[1]
-                ##### just added
-                #print "simfitpage: param name",model_name,param_name
-            
                 param=[str(model_name),param_name,str(param_value)]
-                #print "simfitpage: param",param
                 return param
             else:
-                #raise ValueError,"cannot evaluate this expression"
                 wx.PostEvent(self.parent.Parent,
                               StatusEvent(status="cannot evaluate this expression"))
                 return
         else:
-            #raise ValueError,"Missing '=' in expression"
             wx.PostEvent(self.parent.Parent, StatusEvent(status="Missing '=' in expression"))
             
