Index: sansview/perspectives/fitting/fitpage.py
===================================================================
--- sansview/perspectives/fitting/fitpage.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
+++ sansview/perspectives/fitting/fitpage.py	(revision 948add7b3e543b2f6928425d6b889b3328df699a)
@@ -221,20 +221,23 @@
         flag=self.checkFitRange()
         if flag== True:
-            qmin = float(self.xmin.GetValue())
-            qmax = float(self.xmax.GetValue())
-            x,y,dy = [numpy.asarray(v) for v in (self.data.x,self.data.y,self.data.dy)]
-            if qmin==None and qmax==None: 
-                fx =numpy.asarray([self.model.run(v) for v in x])
-                res=(y - fx)/dy
-            else:
-                idx = (x>= qmin) & (x <=qmax)
-                fx = numpy.asarray([self.model.run(item)for item in x[idx ]])
-                res= (y[idx] - fx)/dy[idx]  
-            
-            sum=0
-            for item in res:
-                if numpy.isfinite(item):
-                    sum +=item
-            self.tcChi.SetValue(format_number(math.fabs(sum)))
+            try:
+                qmin = float(self.xmin.GetValue())
+                qmax = float(self.xmax.GetValue())
+                x,y,dy = [numpy.asarray(v) for v in (self.data.x,self.data.y,self.data.dy)]
+                if qmin==None and qmax==None: 
+                    fx =numpy.asarray([self.model.run(v) for v in x])
+                    res=(y - fx)/dy
+                else:
+                    idx = (x>= qmin) & (x <=qmax)
+                    fx = numpy.asarray([self.model.run(item)for item in x[idx ]])
+                    res= (y[idx] - fx)/dy[idx]  
+                sum=0
+                for item in res:
+                    if numpy.isfinite(item):
+                        sum +=item
+                self.tcChi.SetValue(format_number(math.fabs(sum)))
+            except:
+                wx.PostEvent(self.parent.GrandParent, StatusEvent(status=\
+                            "Chisqr cannot be compute: %s"% sys.exc_value))
             
             
@@ -248,4 +251,5 @@
         qmax =float( self.xmax.GetValue())
         if len(self.param_toFit) >0 and flag==True:
+            self.manager.schedule_for_fit( value=1,fitproblem =None) 
             self.manager._on_single_fit(qmin=qmin,qmax=qmax)
         else:
@@ -546,5 +550,4 @@
                      name=str(item[0].GetLabelText())
                      value= float(item[1].GetValue())
-                     
                      self.model.setParam(name,value)
                      self.manager.redraw_model(float(self.xmin.GetValue())\
Index: sansview/perspectives/fitting/fitproblem.py
===================================================================
--- sansview/perspectives/fitting/fitproblem.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
+++ sansview/perspectives/fitting/fitproblem.py	(revision 948add7b3e543b2f6928425d6b889b3328df699a)
@@ -19,5 +19,5 @@
         self.theory_name=None
         self.model_list=[]
-        self.schedule='False'
+        self.schedule=0
         self.param_name= None
         self.param_value=None
@@ -41,5 +41,5 @@
     def get_model(self):
         """ @return: saved model """
-        print "fitproblem",self.model_list
+        #print "fitproblem",self.model_list
         return self.model_list
      
@@ -68,5 +68,5 @@
             @param value: value of that parameter
         """
-        print "fitproblem",name,value
+        #print "fitproblem",name,value
         #self.model_list[0].setParam(name,value)
         self.param_name = name
@@ -78,5 +78,5 @@
             @param value: value of that parameter
         """
-        print self.param_name, self.param_value
+        #print self.param_name, self.param_value
         #self.model_list[0].setParam(name,value)
         return self.param_name, self.param_value
@@ -87,8 +87,8 @@
             @param value: new model
         """
-        print "fitproblem : reset model"
+        #print "fitproblem : reset model"
         self.model_list[0]=model
         
-    def schedule_tofit(self, schedule='False'):
+    def schedule_tofit(self, schedule=0):
         """
              set schedule to true to decide if this fit  must be performed
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
+++ sansview/perspectives/fitting/fitting.py	(revision 948add7b3e543b2f6928425d6b889b3328df699a)
@@ -158,5 +158,17 @@
                     wx.PostEvent(self.parent, StatusEvent(status="Fitting error: \
                     data already Selected "))
-                    
+    def schedule_for_fit(self,value=0,fitproblem =None):  
+        """
+        
+        """   
+        if fitproblem !=None:
+            fitproblem.schedule_tofit(value)
+        else:
+            current_pg=self.fit_panel.get_current_page() 
+            for page, val in self.page_finder.iteritems():
+                if page ==current_pg :
+                    val.schedule_tofit(value)
+                    break
+                      
                     
     def get_page_finder(self):
@@ -199,5 +211,5 @@
         
         
-    def _single_fit_completed(self,result,pars,current_pg,qmin,qmax):
+    def _single_fit_completed(self,result,pars,cpage,qmin,qmax):
         """
             Display fit result on one page of the notebook.
@@ -211,5 +223,5 @@
         try:
             for page, value in self.page_finder.iteritems():
-                if page== current_pg:
+                if page==cpage :
                     data = value.get_data()
                     list = value.get_model()
@@ -229,6 +241,6 @@
 #            print "fitting result : stderr",result.stderr
             
-            current_pg.onsetValues(result.fitness, result.pvec,result.stderr)
-            self.plot_helper(currpage=current_pg,qmin=qmin,qmax=qmax)
+            cpage.onsetValues(result.fitness, result.pvec,result.stderr)
+            self.plot_helper(currpage=cpage,qmin=qmin,qmax=qmax)
         except:
             raise
@@ -245,5 +257,5 @@
         try:
             for page, value in self.page_finder.iteritems():
-                if value.get_scheduled()=='True':
+                if value.get_scheduled()==1:
                     data = value.get_data()
                     list = value.get_model()
@@ -276,4 +288,5 @@
             
         """
+        #print "in single fitting"
         #set an engine to perform fit
         from sans.fit.Fitting import Fit
@@ -283,46 +296,46 @@
             id=0
         self.id = id
+        page_fitted=None
+        fit_problem=None
         #Get information (model , data) related to the page on 
         #with the fit will be perform
         current_pg=self.fit_panel.get_current_page() 
+        simul_pg=self.fit_panel.get_page(0)
+            
         for page, value in self.page_finder.iteritems():
-            if page ==current_pg :
+            if  value.get_scheduled() ==1 :
                 data = value.get_data()
                 list=value.get_model()
                 model=list[0]
-                
                 #Create list of parameters for fitting used
                 pars=[]
                 templist=[]
                 try:
-                    templist=current_pg.get_param_list()
+                    #templist=current_pg.get_param_list()
+                    templist=page.get_param_list()
+                    for element in templist:
+                        pars.append(str(element[0].GetLabelText()))
+                    pars.sort()
+                    #Do the single fit
+                    self.fitter.set_model(Model(model), self.id, pars) 
+                    self.fitter.set_data(Data(sans_data=data),self.id,qmin,qmax)
+                    self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled())
+                    page_fitted=page
+                    self.id+=1
+                    self.schedule_for_fit( 0,value) 
                 except:
                     wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value))
                     return
-              
-                for element in templist:
-                    try:
-                       pars.append(str(element[0].GetLabelText()))
-                    except:
-                        wx.PostEvent(self.parent, StatusEvent(status="Fitting error: %s" % sys.exc_value))
-                        return
                 # make sure to keep an alphabetic order 
-                #of parameter names in the list
-                pars.sort()
-                #Do the single fit
-                try:
-                    self.fitter.set_model(Model(model), self.id, pars) 
-                    #print "fitting: data .x",data.x
-                    #print "fitting: data .y",data.y
-                    #print "fitting: data .dy",data.dy
-                    self.fitter.set_data(Data(sans_data=data),self.id,qmin,qmax)
-                
-                    result=self.fitter.fit()
-                    self._single_fit_completed(result,pars,current_pg,qmin,qmax)
-                   
-                except:
-                    raise
-                    wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value))
-                    return
+                #of parameter names in the list      
+        try:
+            result=self.fitter.fit()
+            #self._single_fit_completed(result,pars,current_pg,qmin,qmax)
+            print "single_fit: result",result.fitness,result.pvec,result.stderr
+            #self._single_fit_completed(result,pars,page,qmin,qmax)
+            self._single_fit_completed(result,pars,page_fitted,qmin,qmax)
+        except:
+            wx.PostEvent(self.parent, StatusEvent(status="Single Fit error: %s" % sys.exc_value))
+            return
          
     def _on_simul_fit(self, id=None,qmin=None,qmax=None):
@@ -346,5 +359,5 @@
         for page, value in self.page_finder.iteritems():
             try:
-                if value.get_scheduled()=='True':
+                if value.get_scheduled()==1:
                     data = value.get_data()
                     list = value.get_model()
@@ -363,9 +376,10 @@
                     new_model=Model(model)
                     param_name,param_value=value.get_model_param()
-                    print "fitting ",param_name
-                    new_model.set( param_name =str(param_value))
-                    #self.fitter.set_model(new_model, self.id, pars) 
+                    print "fitting ",param_name,value.get_model_param()
+                    if param_value !=None:
+                        new_model.set( param_name =str(param_value))
+                    self.fitter.set_model(new_model, self.id, pars) 
                     self.fitter.set_data(Data(sans_data=data),self.id,qmin,qmax)
-                
+                    self.fitter.select_problem_for_fit(Uid=self.id,value=value.get_scheduled())
                     self.id += 1 
             except:
Index: sansview/perspectives/fitting/simfitpage.py
===================================================================
--- sansview/perspectives/fitting/simfitpage.py	(revision 0056173917543f1d2329e6d57462f61b0b92d261)
+++ sansview/perspectives/fitting/simfitpage.py	(revision 948add7b3e543b2f6928425d6b889b3328df699a)
@@ -44,6 +44,5 @@
 
         self.ctl2 = wx.TextCtrl(self, -1, style=wx.TE_MULTILINE)
-        #self.ctl2.Bind(wx.EVT_KILL_FOCUS, self._onTextEnter)
-        #self.ctl2.Bind(wx.EVT_TEXT_ENTER, self._onTextEnter)
+       
         self.sizer2.Add(self.ctl2, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
        
@@ -65,7 +64,11 @@
     def onFit(self,event):
         """ signal for fitting"""
-        self._onTextEnter()
-        if len(self.model_toFit) >0 :
+        
+        if len(self.model_toFit) ==1 :
+            self.manager._on_single_fit()
+            print "simfitpage: when here"
+        elif len(self.model_toFit) > 1 :
             if len(self.params)>0:
+                self._onTextEnter()
                 self.set_model()
             else:
@@ -94,10 +97,14 @@
             for item in self.model_list:
                 item[0].SetValue(True)
-                item[1].schedule_tofit('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"
+            self.manager.schedule_for_fit( value=0,fitproblem =item[1]) 
             for item in self.model_list:
                 item[0].SetValue(False) 
-                item[1].schedule_tofit('False')
+                #item[1].schedule_tofit(0)
+                
             self.model_toFit=[]
        
@@ -113,4 +120,5 @@
         self.sizer1.Clear(True)
         self.page_finder=page_finder
+        self.cb1.SetValue(False)
         ix = 0
         iy = 1 
@@ -139,5 +147,5 @@
     def remove_model(self,delpage):
         """
-             Remove  a checkbox and the name realted to a model selected on page delpage
+             Remove  a checkbox and the name related to a model selected on page delpage
              @param delpage: the page removed
         """
@@ -147,4 +155,6 @@
         for item in self.model_list:
             try:
+                # redraw the panel without the name of the model associated 
+                # with the page to delete
                 if not delpage in item:
                     #print "simfitpage:  redraw modelname",item[3]
@@ -156,7 +166,9 @@
                     wx.EVT_CHECKBOX(self, cb.GetId(), self.select_model_name)
                 else:
+                    # if the page to delete in item remove it from the model list
                     self.model_list.remove(item)
             except:
-                raise
+                 wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Page deletion Error: %s" % sys.exc_value))
+                 
         self.sizer1.Layout()        
         self.vbox.Layout()
@@ -172,8 +184,12 @@
                 item[1].schedule_tofit('True')
                 self.model_toFit.append(item)
-            else:
+                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:
                     self.model_toFit.remove(item)
-                    item[1].schedule_tofit('False')
+                    
+                    
                     self.cb1.SetValue(False)
         if len(self.model_list)==len(self.model_toFit):
@@ -181,5 +197,6 @@
         else:
             self.cb1.SetValue(False)
-  
+     
+        
    
     def set_model(self):
@@ -235,4 +252,5 @@
                 except:
                      wx.PostEvent(self.parent.GrandParent, StatusEvent(status="Constraint Error: %s" % sys.exc_value))
+                     return
         except:
             raise
