Index: sansview/perspectives/fitting/basepage.py
===================================================================
--- sansview/perspectives/fitting/basepage.py	(revision f9de20e596650290ce4e81429a2ef1bca8385b12)
+++ sansview/perspectives/fitting/basepage.py	(revision b421b1a08ae7adfc77e2f7190153fd10bd1931b9)
@@ -19,5 +19,5 @@
 #Control panel width 
 if sys.platform.count("win32")>0:
-    PANEL_WIDTH = 440
+    PANEL_WIDTH = 450
 else:
     PANEL_WIDTH = 500
@@ -55,4 +55,5 @@
         ## selected parameters to apply dispersion
         self.disp_cb_dict ={}
+
         ## smearer object
         self.smearer = None
@@ -497,5 +498,5 @@
         
         self.state.engine_type = self.engine_type
-       
+
         new_state = self.state.clone()
         new_state.model.name = self.state.model.name
@@ -670,4 +671,5 @@
                if hasattr(self,"cb1"):
                    self.state.cb1= self.cb1.GetValue()
+
         except:
             pass
@@ -704,4 +706,5 @@
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
+           
         ## save plotting range
         self._save_plotting_range()
@@ -719,5 +722,4 @@
         self._copy_parameters_state(self.orientation_params_disp,
                                      self.state.orientation_params_disp)
-        
         self._copy_parameters_state(self.parameters, self.state.parameters)
         self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
@@ -743,9 +745,9 @@
         self.enable2D= state.enable2D
         self.engine_type = state.engine_type
+
         #???
         self.disp_cb_dict = state.disp_cb_dict
-        self.disp_list =state.disp_list
-
-       
+        self.disp_list = state.disp_list
+
         ## set the state of the radio box
         self.shape_rbutton.SetValue(state.shape_rbutton )
@@ -817,5 +819,5 @@
                     
             else:
-
+                
                 for k,v in self.state.disp_cb_dict.iteritems():
                     self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
@@ -1016,8 +1018,7 @@
             item_page_info = statelist[j]
             ##change the state of the check box for simple parameters
-            if item_page[0]!=None:
-               
+            if item_page[0]!=None:               
                 item_page[0].SetValue(item_page_info[0])
-                #print "item_page[0]",item_page[0].GetValue()
+                
             if item_page[2]!=None:
                 item_page[2].SetValue(item_page_info[2])
@@ -1040,5 +1041,5 @@
                 if item_page_info[5][0]:
                     item_page[5].Show(True)
-                    item_page[5].SetValue(item_page_info[4][1])
+                    item_page[5].SetValue(item_page_info[5][1])
                 else:
                     item_page[5].Hide()
@@ -1404,4 +1405,5 @@
         self._disp_obj_dict = {}
         self.disp_cb_dict ={}
+        
         f_id = self.formfactorbox.GetCurrentSelection()
         #For MAC
@@ -1439,9 +1441,7 @@
         self.state.parameters =[]
         self.state.model =self.model
-        
         self.disp_list =self.model.getDispParamList()
         self.state.disp_list = self.disp_list
         self.sizer4_4.Layout()
-        self.sizer4.Layout()
         self.Layout()
         self.SetScrollbars(20,20,25,65)
@@ -1493,4 +1493,5 @@
                 param_min= None
                 param_max= None
+
                 if item[5]!= None:
                     if item[5].GetValue().lstrip().rstrip()!="":
@@ -1508,5 +1509,5 @@
                         wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
                 if name in self.model.details.keys():   
-                    self.model.details[name][1:3]= param_min,param_max
+                    self.model.details[name][1:]= param_min,param_max
                                     
                 ## hide statictext +/-    
@@ -1519,4 +1520,5 @@
 
                 value= float(item[2].GetValue())
+                #print "val", value,self.model.getParam(name)
                 # If the value of the parameter has changed,
                 # +update the model and set the is_modified flag
@@ -1549,9 +1551,5 @@
       
             return
-        #remove previous added details for dispersion parameters.
-        #for item in self.model.dispersion.keys():#for item in self.model.details.keys():
-        #    if item in self.model.fixed and item in self.model.details.keys():
-        #        del self.model.details [item]                           
-    
+
         if self.enable_disp.GetValue():
             self.model_disp.Show(True)
@@ -1662,5 +1660,4 @@
              self.disp_list should change type later .now only gaussian
         """
-
         n = self.disp_box.GetCurrentSelection()
         name = self.disp_box.GetValue()
Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision f9de20e596650290ce4e81429a2ef1bca8385b12)
+++ sansview/perspectives/fitting/fitpage.py	(revision b421b1a08ae7adfc77e2f7190153fd10bd1931b9)
@@ -44,4 +44,5 @@
         ## default fitengine type
         self.engine_type = None
+
         ## draw sizer
         self._fill_datainfo_sizer()
@@ -137,5 +138,5 @@
                     item[6].Show(True)
         self.Layout()
-        #self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20,20,25,65)
         
     
@@ -283,6 +284,7 @@
             ## the user didn't select dispersity display
             return 
-
+            
         self._reset_dispersity()
+        
         # Create the dispersion objects
         for item in self.model.dispersion.keys():
@@ -292,4 +294,5 @@
             self.model.set_dispersion(item, disp_model)
             self.state._disp_obj_dict[item]= disp_model
+
 
         ix=0
@@ -320,8 +323,4 @@
                         
         
-        
-        
-        
-        
         ix += 1 
         npts = wx.StaticText(self, -1, 'Npts')
@@ -337,10 +336,11 @@
         for item in self.model.dispersion.keys():
             if not item in self.model.orientation_params:
-                self.disp_cb_dict[item]= None
+                #if not self.disp_cb_dict.has_key(item):
+                #    self.disp_cb_dict[item]= None
                 name1=item+".width"
                 name2=item+".npts"
                 name3=item+".nsigmas"
                 if not self.model.details.has_key(name1):
-                    self.model.details [name1] = ["",None, None, None]                            
+                    self.model.details [name1] = ["",None,None] 
 
                 iy += 1
@@ -365,19 +365,17 @@
                                           wx.EXPAND|wx.ADJUST_MINSIZE, 0)
                         text2.Hide() 
-                        ## txtcrtl to add error from fit
-                        fit_errs = self.model.details[item][3]
-                     
+
                         ix = 3
                         ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                        ctl2.SetValue(str(format_number(fit_errs)))
+                        #ctl2.SetValue(str(format_number(fit_errs)))
                         self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                        if fit_errs==None or not numpy.isfinite(fit_errs):
-                            ctl2.Hide()
-                        else:
-                            if not text2.IsShown():
-                                text2.Show(True)
-                            ctl2.Show(True)
-                        #Prepare add min and max in model.details.(Maybe Not correct way)
-                        param_min, param_max= self.model.details[name1][1:3]
+                        #if fit_errs==None or not numpy.isfinite(fit_errs):
+                        ctl2.Hide()
+                        #else:
+                        #    if not text2.IsShown():
+                        #        text2.Show(True)
+                        #    ctl2.Show(True)
+                        #Prepare add min and max in model.details.
+                        param_min, param_max= self.model.details[name1][1:]
                         ix = 4
                         ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,
@@ -440,10 +438,12 @@
         for item in self.model.dispersion.keys():
             if  item in self.model.orientation_params:
-                self.disp_cb_dict[item]= None
+     
                 name1=item+".width"
                 name2=item+".npts"
                 name3=item+".nsigmas"
                 if not self.model.details.has_key(name1):
-                    self.model.details [name1] = ["",None, None, None]                  
+                    self.model.details [name1] = ["",None,None]                  
+ 
+
                 iy += 1
                 for p in self.model.dispersion[item].keys(): 
@@ -475,22 +475,12 @@
                                           wx.EXPAND|wx.ADJUST_MINSIZE, 0)
                         text2.Hide() 
-                        ## txtcrtl to add error from fit                       
-                        fit_errs = self.model.details[item][3]                    
+
                         ix = 3
                         ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-                        ctl2.SetValue(str(format_number(fit_errs)))
+                    
                         self.sizer4_4.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                        if fit_errs==None or not numpy.isfinite(fit_errs) or self.data.__class__.__name__ !="Data2D":
-                            ctl2.Hide()
-                        else:
-                            if not text2.IsShown():
-                                text2.Show(True)
-                            ctl2.Show(True)
-                        #if self.data.__class__.__name__ =="Data2D":
-                            #ctl2.Show(True)
-                        #elif ctl2.IsShown():
-                            #ctl2.Hide()
+                        ctl2.Hide()
                             
-                        param_min, param_max= self.model.details[name1][1:3]
+                        param_min, param_max= self.model.details[name1][1:]
                         ix = 4
                         ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,
@@ -571,13 +561,9 @@
                                                      ,None,None, None, None,None])
         #Display units text on panel
-        for item in self.model.dispersion.keys():   
-            if self.model.details[item][3]!= None and numpy.isfinite(self.model.details[item][3]):
-                if not self.text2_3.IsShown():
-                    self.text2_3.Show()
-                break
-            else:
-                self.text2_3.Hide()
+        for item in self.model.dispersion.keys(): 
+            name = item +".width"  
    
-        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)      
+        self.state.disp_cb_dict = copy.deepcopy(self.disp_cb_dict)  
+          
         self.state.model = self.model.clone()  
          ## save state into
@@ -664,5 +650,5 @@
         self._on_select_model_helper() 
         self.set_model_param_sizer(self.model)                   
-       
+        
         self.enable_disp.SetValue(False)
         self.disable_disp.SetValue(True)
@@ -742,5 +728,5 @@
         """
         tcrtl= event.GetEventObject()
-
+        
         if check_float(tcrtl):
             self._onparamEnter_helper()
@@ -808,12 +794,11 @@
             reset the state
         """
+        self.reset_page_helper(state)
         import sans.guiframe.gui_manager
-        
-        self.reset_page_helper(state)
         evt = ModelEventbox(model=state.model)
         wx.PostEvent(self.event_owner, evt)
+    
         self.manager._on_change_engine(engine=self.engine_type)
-        #Not improving anything yet.
-        #self.set_model_param_sizer(model=state.model)
+    
             
     def get_range(self):
@@ -889,12 +874,10 @@
                     self.param_toFit[0][4].Refresh()
         else:
-            i=0
-            j=0
-            k=0
-            
+            #i=0
             if self.text2_3.IsShown():
                 self.text2_3.Hide()
-                
+            #print "fittable",self.print "fittable",self.fittable_param[p_name]    
             #Set the panel when fit result are list
+
             for item in self.param_toFit:               
                 ## reset error value to initial state
@@ -904,9 +887,14 @@
                     item[4].Hide()
        
-                if( out != None ) and len(out)<=len(self.param_toFit)and i < len(out):
+                if( out != None ) and len(out)<=len(self.param_toFit):#and i < len(out):
                     item[2].SetValue(format_number(self.model.getParam(item[1])))
                     item[2].Refresh()
-
-                if(cov !=None)  and len(cov)<=len(self.param_toFit)and i < len(cov):
+                    
+                for ind in range(len(out)):
+                    
+                    if item[1] == p_name[ind]:
+                        break        
+
+                if(cov !=None)  and len(cov)<=len(self.param_toFit):#and i < len(cov):
                     try:
                         name= dispersity.__name__
@@ -917,13 +905,5 @@
                     except:
                         pass                   
-                    for j in range(len(out)):
-                        
-                        if item[1] == p_name[j]:
-                            break
-                        ## unable to compare cov[j]==numpy.nan so switch to None
-                    #Save errors to model.details[item][3]
-                    self.model.details[item[1]][3] = cov[j]
-                                                           
-                    if cov[j]==None or not numpy.isfinite(cov[j]):
+                    if cov[ind]==None or not numpy.isfinite(cov[ind]):
 
                         if item[3].IsShown:
@@ -933,22 +913,25 @@
                         #k += 1   
 
-                    else:
-                        k += 1
+                    else:                        
                         item[3].Show(True)
                         item[3].Refresh()
                         item[4].Show(True)
-                        item[4].SetValue(format_number(cov[j]))
+                        item[4].SetValue(format_number(cov[ind]))
                         item[4].Refresh()
+                        has_error = True
                     
  
-                i+=1  
+               # i+=1  
         #Show error title when any errors displayed
-        if k != 0: # len(self.param_toFit):
+        if has_error: 
             if not self.text2_3.IsShown():
                 self.text2_3.Show(True)                            
-
-        self.text2_3.Layout()             
+        ## save current state
+        self.save_current_state()
+
+        self.text2_3.Layout() 
+        self.sizer3.Layout()           
         self.Layout()
-        
+        self.Refresh()
         
     def onSmear(self, event):
@@ -1154,4 +1137,5 @@
         for item in self.fittable_param:
             if item[0].GetValue():
+                #print item[0].GetValue()
                 if not (item in self.param_toFit):
                     self.param_toFit.append(item)  
@@ -1205,5 +1189,5 @@
         #list of dispersion paramaters
         self.disp_list=self.model.getDispParamList()
-       
+
         keys.sort()
     
@@ -1243,10 +1227,12 @@
             self.text2_max.Show(True)
             self.text2_min.Show(True)
-
+        
         for item in keys:
             if not item in self.disp_list and not item in self.model.orientation_params:
-                ##prepare a spot for error
-                if len(self.model.details[item])<4:
-                    self.model.details[item].append(numpy.nan)                
+                
+                ##prepare a spot to store errors
+                if not self.model.details.has_key(item):
+                    self.model.details [item] = ["",None,None] 
+         
                 iy += 1
                 ix = 0
@@ -1272,23 +1258,10 @@
                                 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
                 text2.Hide() 
-                ## txtcrtl to add error from fit
-                fit_errs = self.model.details[item][3]
-
                 ix += 1
                 ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
-
+                sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                ctl2.Hide()
                 
-                ctl2.SetValue(str(format_number(fit_errs)))
-                sizer.Add(ctl2, (iy,ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-                if fit_errs==None or not numpy.isfinite(fit_errs):                   
-                    ctl2.Hide()
-                else:
-                    if not self.text2_3.IsShown():
-                        self.text2_3.Show(True)
-                    if not text2.IsShown():
-                        text2.Show(True) 
-                    ctl2.Show(True)
-                
-                param_min, param_max= self.model.details[item][1:3]
+                param_min, param_max= self.model.details[item][1:]
                 ix += 1
                 ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,
@@ -1354,6 +1327,5 @@
             for item in self.model.orientation_params:
                 if not item in self.disp_list:
-                    if len(self.model.details[item])<4:
-                        self.model.details[item].append(numpy.nan)    
+                         
                     iy += 1
                     ix = 0
@@ -1387,6 +1359,4 @@
                                     wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
                     text2.Hide() 
-                    ## txtcrtl to add error from fit
-                    fit_errs = self.model.details[item][3]
                     ix += 1
                     ctl2 = wx.TextCtrl(self, -1, size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
@@ -1395,12 +1365,12 @@
                     ctl2.Hide()
                     if self.data.__class__.__name__ !="Data2D":
-                            ctl2.Hide()
+                        ctl2.Hide()
                     else:
-                        if fit_errs!=None and numpy.isfinite(fit_errs):
-                            if not text2.IsShown():
-                                text2.Show(True)
-                            ctl2.Show(True)
+                      
+                        if not text2.IsShown():
+                            text2.Show(True)
+                        ctl2.Show(True)
                     
-                    param_min, param_max= self.model.details[item][1:3]
+                    param_min, param_max= self.model.details[item][1:]
                     ix += 1
                     ctl3 = BasicPage.ModelTextCtrl(self, -1, size=(_BOX_WIDTH/2,20), style=wx.TE_PROCESS_ENTER,
@@ -1481,4 +1451,5 @@
         #self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
         #self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
+ 
         self.save_current_state_fit()
         boxsizer1.Add(sizer)
Index: sansview/perspectives/fitting/pagestate.py
===================================================================
--- sansview/perspectives/fitting/pagestate.py	(revision c99a6c514c56374f21266b358ae99f1145058839)
+++ sansview/perspectives/fitting/pagestate.py	(revision b421b1a08ae7adfc77e2f7190153fd10bd1931b9)
@@ -123,5 +123,4 @@
         obj.orientation_params =  copy.deepcopy(self.orientation_params)
         obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
-        
         obj.enable_disp = copy.deepcopy(self.enable_disp)
         obj.disable_disp = copy.deepcopy(self.disable_disp)
@@ -134,9 +133,10 @@
             for k , v in self.disp_cb_dict.iteritems():
                 obj.disp_cb_dict[k]= v
+                
         obj.values = copy.deepcopy(self.values)
         obj.weights = copy.deepcopy(self.weights)
         obj.enable_smearer = copy.deepcopy(self.enable_smearer)
         obj.disable_smearer = copy.deepcopy(self.disable_smearer)
-        
+       
         obj.disp_box = copy.deepcopy(self.disp_box)
         obj.qmin = copy.deepcopy(self.qmin)
