Index: sansview/perspectives/fitting/console.py
===================================================================
--- sansview/perspectives/fitting/console.py	(revision e54d2c324bf84217d78d7d712832df44f61bec2d)
+++ sansview/perspectives/fitting/console.py	(revision e54d2c324bf84217d78d7d712832df44f61bec2d)
@@ -0,0 +1,118 @@
+
+
+
+from sans.guicomm.events import StatusEvent 
+import time
+import wx
+import park
+from park.fitresult import FitHandler
+
+class ConsoleUpdate(FitHandler):
+    """
+    Print progress to the console.
+    """
+    isbetter = False
+    """Record whether results improved since last update"""
+    progress_delta =  60
+    """Number of seconds between progress updates"""
+    improvement_delta = 5
+    """Number of seconds between improvement updates"""
+    def __init__(self,parent, quiet=False,progress_delta=60,improvement_delta=5):
+        """
+        If quiet is true, only print out final summary, not progress and
+        improvements.
+        """
+        self.parent= parent
+        self.progress_time = time.time()
+        self.progress_percent = 0
+        self.improvement_time = self.progress_time
+        self.isbetter = False
+        self.quiet = quiet
+        self.progress_delta = progress_delta
+        self.improvement_delta = improvement_delta
+        self.elapsed_time = self.progress_time
+        
+    def progress(self, k, n):
+        """
+        Report on progress.
+        """
+        if self.quiet: return
+
+        t = time.time()
+        p = int((100*k)//n)
+        
+        # Show improvements if there are any
+        dt = t - self.improvement_time
+        if self.isbetter and dt > self.improvement_delta:
+            self.result.print_summary()
+            self.isbetter = False
+            self.improvement_time = t
+            
+            wx.PostEvent(self.parent, StatusEvent(status=\
+             "%d%% complete ..."%(p),type="progress"))
+       
+        # Update percent complete
+        dp = p-self.progress_percent
+        if dp < 1: return
+        dt = t - self.progress_time
+        if dt > self.progress_delta:
+            if 1 <= dp <= 2:
+                self.progress_percent = p
+                self.progress_time = t
+                wx.PostEvent(self.parent, StatusEvent(status=\
+                                                      "%d%% complete ..."%(p),
+                                                      type="progress"))
+       
+            elif 2 < dp <= 5:
+                if p//5 != self.progress_percent//5:
+                    wx.PostEvent(self.parent, StatusEvent(status=\
+                       "%d%% complete ..."%(5*(p//5)),type="progress"))
+                    self.progress_percent = p
+                    self.progress_time = t
+            else:
+                if p//10 != self.progress_percent//10:
+                    self.progress_percent = p
+                    self.progress_time = t
+                    wx.PostEvent(self.parent, StatusEvent(status=\
+                   "%d%% complete ..."%(10*(p//10)),type="progress"))
+        
+    def improvement(self):
+        """
+        Called when a result is observed which is better than previous
+        results from the fit.
+        """
+        self.isbetter = True
+    
+    def error(self, msg):
+        """
+        Model had an error; print traceback
+        """
+        if self.isbetter:
+            self.result.print_summary()
+        message = "fit Error"
+        message = str(msg)+ " \n %s"%self.result.__str__()
+        wx.PostEvent(self.parent, StatusEvent(status=message,
+                                              info="error", type="stop"))
+            
+    def finalize(self):
+        if self.isbetter:
+            self.result.print_summary()
+
+    def abort(self):
+        if self.isbetter:
+            self.result.print_summary()
+            
+    def update_fit(self, msg=""):
+        self.elapsed_time = time.time() - self.elapsed_time
+        msg = " Updating fit ...\n result:\n %s \n"%self.result.__str__()
+        wx.PostEvent(self.parent, StatusEvent(status=msg, info="info",
+                                              type="progress"))
+        
+    def starting_fit(self):
+        wx.PostEvent(self.parent, StatusEvent(status="Starting the Fit...",
+                                        info="info",type="progress"))
+        
+    def set_result(self, result):
+        self.result = result
+        
+    
Index: sansview/perspectives/fitting/fit_thread.py
===================================================================
--- sansview/perspectives/fitting/fit_thread.py	(revision 25e3fc9206f3a71ae3802b4eaa7aed1f169ed5b9)
+++ sansview/perspectives/fitting/fit_thread.py	(revision e54d2c324bf84217d78d7d712832df44f61bec2d)
@@ -1,106 +1,14 @@
 
-import sys, wx, logging
-import string, numpy, math
-from sans.guicomm.events import NewPlotEvent, StatusEvent  
+
 from data_util.calcthread import CalcThread
-import park
-from park.fitresult import FitHandler
-DEFAULT_BEAM = 0.005
-import time
-import thread
- 
-class ConsoleUpdate(FitHandler):
-    """
-    Print progress to the console.
-    """
-    isbetter = False
-    """Record whether results improved since last update"""
-    progress_delta =  60
-    """Number of seconds between progress updates"""
-    improvement_delta = 5
-    """Number of seconds between improvement updates"""
-    def __init__(self,parent, quiet=False,progress_delta=60,improvement_delta=5):
-        """
-        If quiet is true, only print out final summary, not progress and
-        improvements.
-        """
-        self.parent= parent
-        self.progress_time = time.time()
-        self.progress_percent = 0
-        self.improvement_time = self.progress_time
-        self.isbetter = False
-        self.quiet = quiet
-        self.progress_delta = progress_delta
-        self.improvement_delta = improvement_delta
-
-    def progress(self, k, n):
-        """
-        Report on progress.
-        """
-        if self.quiet: return
-        t = time.time()
-        p = int((100*k)//n)
-        
-        # Show improvements if there are any
-        dt = t - self.improvement_time
-        if self.isbetter and dt > self.improvement_delta:
-            self.result.print_summary()
-            self.isbetter = False
-            self.improvement_time = t
-            
-            wx.PostEvent(self.parent, StatusEvent(status=\
-             "%d%% complete ..."%(p),type="update"))
-       
-        # Update percent complete
-        dp = p-self.progress_percent
-        if dp < 1: return
-        dt = t - self.progress_time
-        if dt > self.progress_delta:
-            if 1 <= dp <= 2:
-                self.progress_percent = p
-                self.progress_time = t
-                wx.PostEvent(self.parent, StatusEvent(status=\
-                                                      "%d%% complete ..."%(p),type="update"))
-       
-            elif 2 < dp <= 5:
-                if p//5 != self.progress_percent//5:
-                    wx.PostEvent(self.parent, StatusEvent(status=\
-                       "%d%% complete ..."%(5*(p//5)),type="update"))
-                    self.progress_percent = p
-                    self.progress_time = t
-            else:
-                if p//10 != self.progress_percent//10:
-                    self.progress_percent = p
-                    self.progress_time = t
-                    wx.PostEvent(self.parent, StatusEvent(status=\
-                   "%d%% complete ..."%(10*(p//10)),type="update"))
-        
-    def improvement(self):
-        """
-        Called when a result is observed which is better than previous
-        results from the fit.
-        """
-        self.isbetter = True
-    
-    def error(self, msg):
-        """
-        Model had an error; print traceback
-        """
-        if self.isbetter:
-            self.result.print_summary()
-        print msg
-
-    def finalize(self):
-        if self.isbetter:
-            self.result.print_summary()
-
-    def abort(self):
-        if self.isbetter:
-            self.result.print_summary()
 
 class FitThread(CalcThread):
     """Thread performing the fit """
     
-    def __init__(self,parent, fn,pars=None,cpage=None,
+    def __init__(self, parent,
+                  fn,
+                   handler,
+                  pars=None,
+                 cpage=None,
                  completefn = None,
                  updatefn   = None,
@@ -113,11 +21,11 @@
                  worktime)
         self.parent = parent
-        self.fitter= fn
+        self.handler = handler
+        self.fitter = fn
         self.cpage= cpage
         self.pars = pars
         self.starttime = 0
-       
-        self.done= False
-       
+        self.updatefn = updatefn
+   
     def isquit(self):
         """
@@ -134,27 +42,22 @@
         """
         try: 
-            self.starttime = time.time()
-        
-            #Handler used for park engine displayed message
-            handler= ConsoleUpdate(parent= self.parent,improvement_delta=0.1)
+            self.handler.starting_fit()
+            self.updatefn()
             #Result from the fit
-            result = self.fitter.fit(handler= handler, curr_thread=self)
-        
-            elapsed = time.time()-self.starttime
+            result = self.fitter.fit(handler=self.handler, curr_thread=self)
+            self.updatefn()
             self.complete(result= result,
                           pars = self.pars,
-                          cpage= self.cpage,
-                          elapsed=elapsed )
+                          cpage= self.cpage)
            
-        except KeyboardInterrupt:
+        except KeyboardInterrupt, msg:
             # Thread was interrupted, just proceed and re-raise.
             # Real code should not print, but this is an example...
             #print "keyboard exception"
-            raise
+            #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar.
+            self.handler.error(msg=msg)
         
-        except :
-            #Stop on exception during fitting. Todo: need to put some mssg and reset progress bar.
-            msg= " Fit Error occurred... %s"%sys.exc_value
-            wx.PostEvent(self.parent, StatusEvent(status= msg,type="stop"))
+            
+         
             
     
Index: sansview/perspectives/fitting/fitting.py
===================================================================
--- sansview/perspectives/fitting/fitting.py	(revision 018a0bd10688822d6c54c6b3ca99ef93b3f1e24d)
+++ sansview/perspectives/fitting/fitting.py	(revision e54d2c324bf84217d78d7d712832df44f61bec2d)
@@ -29,5 +29,5 @@
 from sans.fit.AbstractFitEngine import Model
 from sans.fit.AbstractFitEngine import FitAbort
-
+from console import ConsoleUpdate
 
 from fitproblem import FitProblem
@@ -462,47 +462,29 @@
                                                       type="stop"))
                 return 
-            
-        #Do the simultaneous fit
-        try:
-            ## If a thread is already started, stop it
-            #if self.calc_fit!= None and self.calc_fit.isrunning():
-            #    self.calc_fit.stop()
-            
-            wx.PostEvent(self.parent, StatusEvent(status="Start the computation",
-                                        curr_thread=self.calc_fit,type="start"))
-            time.sleep(0.5)
-            wx.PostEvent(self.parent, StatusEvent(status="Computing...",
-                                        curr_thread=self.calc_fit,type="progress"))
-            time.sleep(0.5)
-            ## perform single fit
-            if fitproblem_count == 1:
-                #qmin, qmax= self.current_pg.get_range()
-                #print "went here fitproblem_count == 1",fitproblem_count == 1
-                calc_fit=FitThread(parent =self.parent,
-                                        fn= self.fitter,
-                                       cpage=self.current_pg,
-                                       pars= pars,
-                                       completefn= self._single_fit_completed,
-                                       updatefn=self._updateFit)
-                
-                      
-            else:
-                ## Perform more than 1 fit at the time
-                calc_fit=FitThread(parent =self.parent,
-                                        fn= self.fitter,
-                                       completefn= self._simul_fit_completed,
-                                       updatefn=self._updateFit)
-            
-            calc_fit.queue()
-            self.ready_fit(calc_fit=calc_fit)
-            
-        except FitAbort:
-            print "in pluging"
-        except:
-            msg= "%s error: %s" % (engineType,sys.exc_value)
-            wx.PostEvent(self.parent, StatusEvent(status=msg, info="error",
-                                                    type="stop"))
-            return 
-        
+        ## If a thread is already started, stop it
+        #if self.calc_fit!= None and self.calc_fit.isrunning():
+        #    self.calc_fit.stop()
+         #Handler used for park engine displayed message
+        handler = ConsoleUpdate(parent=self.parent,improvement_delta=0.1)
+        ## perform single fit
+        if fitproblem_count == 1:
+            calc_fit=FitThread(parent =self.parent,
+                                    handler = handler,
+                                    fn= self.fitter,
+                                   cpage=self.current_pg,
+                                   pars= pars,
+                                   updatefn=handler.update_fit,
+                                   completefn= self._single_fit_completed)
+        else:
+            ## Perform more than 1 fit at the time
+            calc_fit=FitThread(parent=self.parent,
+                                handler=handler,
+                                    fn= self.fitter,
+                                   completefn= self._simul_fit_completed,
+                                  updatefn=handler.update_fit)
+        
+        calc_fit.queue()
+        self.ready_fit(calc_fit=calc_fit)
+      
     def ready_fit(self, calc_fit):
         """
@@ -740,11 +722,4 @@
                 data = self.create_fittable_data2D(data=plottable)
                 self.add_fit_page(data=data)
-
-    def _updateFit(self):
-        """
-            Is called when values of result are available
-        """
-        ##Sending a progess message to the status bar
-        wx.PostEvent(self.parent, StatusEvent(status="Computing..."))
             
     def _single_fit_completed(self,result,pars,cpage, elapsed=None):
