Index: fittingview/src/sans/perspectives/fitting/basepage.py
===================================================================
--- fittingview/src/sans/perspectives/fitting/basepage.py	(revision f992a06e61976845619bed3fe4df39c8886b2432)
+++ fittingview/src/sans/perspectives/fitting/basepage.py	(revision ef26c8354b6185342ee4ec2f74e2fe34c632c808)
@@ -5,10 +5,10 @@
 import numpy
 import time
-import copy 
+import copy
 import math
 import string
 from wx.lib.scrolledpanel import ScrolledPanel
 from sans.guiframe.panel_base import PanelBase
-from sans.guiframe.utils import format_number,check_float
+from sans.guiframe.utils import format_number, check_float
 from sans.guiframe.events import PanelOnFocusEvent
 from sans.guiframe.events import StatusEvent
@@ -22,7 +22,7 @@
 from pagestate import PageState
 
-(PageInfoEvent, EVT_PAGE_INFO)   = wx.lib.newevent.NewEvent()
-(PreviousStateEvent, EVT_PREVIOUS_STATE)   = wx.lib.newevent.NewEvent()
-(NextStateEvent, EVT_NEXT_STATE)   = wx.lib.newevent.NewEvent()
+(PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent()
+(PreviousStateEvent, EVT_PREVIOUS_STATE) = wx.lib.newevent.NewEvent()
+(NextStateEvent, EVT_NEXT_STATE) = wx.lib.newevent.NewEvent()
 
 _BOX_WIDTH = 76
@@ -30,6 +30,6 @@
 _QMAX_DEFAULT = 0.5
 _NPTS_DEFAULT = 50
-#Control panel width 
-if sys.platform.count("win32")> 0:
+#Control panel width
+if sys.platform.count("win32") > 0:
     PANEL_WIDTH = 450
     FONT_VARIANT = 0
@@ -41,15 +41,14 @@
 
 
-
 class BasicPage(ScrolledPanel, PanelBase):
     """
     This class provide general structure of  fitpanel page
     """
-     ## Internal name for the AUI manager
+    ## Internal name for the AUI manager
     window_name = "Fit Page"
     ## Title to appear on top of the window
     window_caption = "Fit Page "
     
-    def __init__(self, parent,color='blue', **kwargs):
+    def __init__(self, parent, color='blue', **kwargs):
         """
         """
@@ -57,5 +56,5 @@
         PanelBase.__init__(self, parent)
         self.SetupScrolling()
-        #Set window's font size 
+        #Set window's font size
         self.SetWindowVariant(variant=FONT_VARIANT)
       
@@ -66,5 +65,5 @@
         ## owner of the page (fitting plugin)
         self.event_owner = None
-         ## current model
+        ## current model
         self.model = None
         self.index_model = None
@@ -94,8 +93,8 @@
         ## 2D smear accuracy default
         self.smear2d_accuracy = 'Low'
-        ## slit smear: 
+        ## slit smear:
         self.dxl = None
         self.dxw = None
-        ## pinhole smear 
+        ## pinhole smear
         self.dx_min = None
         self.dx_max = None
@@ -110,5 +109,5 @@
         self._disp_obj_dict = {}
         ## selected parameters to apply dispersion
-        self.disp_cb_dict ={}
+        self.disp_cb_dict = {}
         ## smearer object
         self.enable2D = False
@@ -152,10 +151,10 @@
         self.number_saved_state = 0
         ## dictionary of saved state
-        self.saved_states = {} 
+        self.saved_states = {}
         ## Create context menu for page
         self.popUpMenu = wx.Menu()
     
         id = wx.NewId()
-        self._keep = wx.MenuItem(self.popUpMenu,id,"Add bookmark",
+        self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark",
                                  " Keep the panel status to recall it later")
         self.popUpMenu.AppendItem(self._keep)
@@ -167,5 +166,5 @@
     
         ## Default locations
-        self._default_save_location = os.getcwd()     
+        self._default_save_location = os.getcwd()
         ## save initial state on context menu
         #self.onSave(event=None)
@@ -177,5 +176,5 @@
         ## create the basic structure of the panel with empty sizer
         self.define_page_structure()
-        ## drawing Initial dispersion parameters sizer 
+        ## drawing Initial dispersion parameters sizer
         self.set_dispers_sizer()
         
@@ -191,5 +190,5 @@
     def create_default_data(self):
         """
-        Given the user selection, creates a 1D or 2D data 
+        Given the user selection, creates a 1D or 2D data
         Only when the page is on theory mode.
         """
@@ -206,6 +205,6 @@
                     self._manager.page_finder[self.uid].set_fit_data(data=[self.data])
             self.on_smear_helper(update=True)
-            self.state.enable_smearer=  self.enable_smearer.GetValue()
-            self.state.disable_smearer=self.disable_smearer.GetValue()
+            self.state.enable_smearer = self.enable_smearer.GetValue()
+            self.state.disable_smearer = self.disable_smearer.GetValue()
             self.state.pinhole_smearer = self.pinhole_smearer.GetValue()
             self.state.slit_smearer = self.slit_smearer.GetValue()
@@ -213,17 +212,17 @@
     def _create_default_1d_data(self):
         """
-        Create default data for fitting perspective 
+        Create default data for fitting perspective
         Only when the page is on theory mode.
         :warning: This data is never plotted.
         
         """
-        x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
+        x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x,
                            num=self.npts_x, endpoint=True)
         self.data = Data1D(x=x)
-        self.data.xaxis('\\rm{Q}',"A^{-1}")
+        self.data.xaxis('\\rm{Q}', "A^{-1}")
         self.data.yaxis('\\rm{Intensity}', "cm^{-1}")
         self.data.is_data = False
-        self.data.id = str(self.uid) + " data" 
-        self.data.group_id = str(self.uid) + " Model1D" 
+        self.data.id = str(self.uid) + " data"
+        self.data.group_id = str(self.uid) + " Model1D"
        
     def _create_default_2d_data(self):
@@ -238,11 +237,11 @@
         self.data.yaxis('\\rm{Q_{y}}', 'A^{-1}')
         self.data.is_data = False
-        self.data.id = str(self.uid) + " data" 
-        self.data.group_id = str(self.uid) + " Model2D" 
-        ## Default values    
-        self.data.detector.append(Detector())  
+        self.data.id = str(self.uid) + " data"
+        self.data.group_id = str(self.uid) + " Model2D"
+        ## Default values
+        self.data.detector.append(Detector())
         index = len(self.data.detector) - 1
-        self.data.detector[index].distance = 8000   # mm        
-        self.data.source.wavelength= 6         # A      
+        self.data.detector[index].distance = 8000   # mm
+        self.data.source.wavelength = 6             # A
         self.data.detector[index].pixel_size.x = 5  # mm
         self.data.detector[index].pixel_size.y = 5  # mm
@@ -250,11 +249,11 @@
         self.data.detector[index].beam_center.y = qmax
         ## create x_bins and y_bins of the model 2D
-        pixel_width_x = self.data.detector[index].pixel_size.x
-        pixel_width_y = self.data.detector[index].pixel_size.y
-        center_x = self.data.detector[index].beam_center.x/pixel_width_x
-        center_y = self.data.detector[index].beam_center.y/pixel_width_y
-        # theory default: assume the beam 
+        #pixel_width_x = self.data.detector[index].pixel_size.x
+        #pixel_width_y = self.data.detector[index].pixel_size.y
+        #center_x = self.data.detector[index].beam_center.x/pixel_width_x
+        #center_y = self.data.detector[index].beam_center.y/pixel_width_y
+        # theory default: assume the beam
         #center is located at the center of sqr detector
-        xmax = qmax 
+        xmax = qmax
         xmin = -qmax
         ymax = qmax
@@ -262,41 +261,41 @@
         qstep = self.npts_x
 
-        x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)  
+        x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)
         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)
         ## use data info instead
         new_x = numpy.tile(x, (len(y), 1))
         new_y = numpy.tile(y, (len(x), 1))
-        new_y = new_y.swapaxes(0,1)
+        new_y = new_y.swapaxes(0, 1)
         # all data reuire now in 1d array
         qx_data = new_x.flatten()
         qy_data = new_y.flatten()
-        q_data = numpy.sqrt(qx_data*qx_data + qy_data*qy_data)
+        q_data = numpy.sqrt(qx_data * qx_data + qy_data * qy_data)
         # set all True (standing for unmasked) as default
         mask = numpy.ones(len(qx_data), dtype=bool)
         # calculate the range of qx and qy: this way,
         # it is a little more independent
-        x_size = xmax - xmin
-        y_size = ymax - ymin
+        #x_size = xmax - xmin
+        #y_size = ymax - ymin
         # store x and y bin centers in q space
-        x_bins  = x
-        y_bins  = y 
+        x_bins = x
+        y_bins = y
         # bin size: x- & y-directions
-        xstep = x_size/len(x_bins-1)
-        ystep = y_size/len(y_bins-1)
+        #xstep = x_size / len(x_bins - 1)
+        #ystep = y_size / len(y_bins - 1)
   
         self.data.source = Source()
         self.data.data = numpy.ones(len(mask))
         self.data.err_data = numpy.ones(len(mask))
-        self.data.qx_data = qx_data 
-        self.data.qy_data = qy_data  
-        self.data.q_data = q_data 
-        self.data.mask = mask            
-        self.data.x_bins = x_bins  
-        self.data.y_bins = y_bins   
+        self.data.qx_data = qx_data
+        self.data.qy_data = qy_data
+        self.data.q_data = q_data
+        self.data.mask = mask
+        self.data.x_bins = x_bins
+        self.data.y_bins = y_bins
         # max and min taking account of the bin sizes
-        self.data.xmin = xmin 
+        self.data.xmin = xmin
         self.data.xmax = xmax
-        self.data.ymin = ymin 
-        self.data.ymax = ymax 
+        self.data.ymin = ymin
+        self.data.ymax = ymax
 
     def on_set_focus(self, event):
@@ -314,12 +313,12 @@
         if self._manager.menu1 != None:
             chain_menu = self._manager.menu1.FindItemById(\
-                                                    self._manager.id_reset_flag)
+                                                   self._manager.id_reset_flag)
             chain_menu.Enable(self.batch_on)
             sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit)
             flag = self.data.is_data\
-                            and (self.model!=None)
+                            and (self.model != None)
             sim_menu.Enable(not self.batch_on and flag)
             batch_menu = self._manager.menu1.FindItemById(self._manager.id_batchfit)
-            batch_menu.Enable(self.batch_on and flag) 
+            batch_menu.Enable(self.batch_on and flag)
     
     class ModelTextCtrl(wx.TextCtrl):
@@ -340,9 +339,9 @@
         _on_set_focus_callback = None
         
-        def __init__(self, parent, id=-1, 
-                     value=wx.EmptyString, 
-                     pos=wx.DefaultPosition, 
+        def __init__(self, parent, id=-1,
+                     value=wx.EmptyString,
+                     pos=wx.DefaultPosition,
                      size=wx.DefaultSize,
-                     style=0, 
+                     style=0,
                      validator=wx.DefaultValidator,
                      name=wx.TextCtrlNameStr,
@@ -350,5 +349,5 @@
                      set_focus_callback=None,
                      mouse_up_callback=None,
-                     text_enter_callback = None):
+                     text_enter_callback=None):
              
             wx.TextCtrl.__init__(self, parent, id, value, pos,
@@ -360,9 +359,9 @@
             self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
             self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \
-                      if kill_focus_callback is None else kill_focus_callback)                
+                      if kill_focus_callback is None else kill_focus_callback)
             self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \
                       if text_enter_callback is None else text_enter_callback)
-            if not ON_MAC :
-                self.Bind(wx.EVT_LEFT_UP,    self._highlight_text \
+            if not ON_MAC:
+                self.Bind(wx.EVT_LEFT_UP, self._highlight_text \
                           if mouse_up_callback is None else mouse_up_callback)
             
@@ -379,6 +378,4 @@
             return self._on_set_focus_callback(event)
         
- 
-            
         def _highlight_text(self, event):
             """
@@ -390,16 +387,16 @@
             # Make sure the mouse event is available to other listeners
             event.Skip()
-            control  = event.GetEventObject()
+            control = event.GetEventObject()
             if self.full_selection:
                 self.full_selection = False
                 # Check that we have a TextCtrl
                 if issubclass(control.__class__, wx.TextCtrl):
-                    # Check whether text has been selected, 
+                    # Check whether text has been selected,
                     # if not, select the whole string
                     (start, end) = control.GetSelection()
-                    if start==end:
-                        control.SetSelection(-1,-1)
+                    if start == end:
+                        control.SetSelection(-1, -1)
                         
-        def _silent_kill_focus(self,event):
+        def _silent_kill_focus(self, event):
             """
             Save the state of the page
@@ -413,13 +410,13 @@
         set some page important information at once
         """
-       ##window_name
+        ##window_name
         self.window_name = page_info.window_name
         ##window_caption
         self.window_caption = page_info.window_caption
         ## manager is the fitting plugin
-        self._manager= page_info.manager
+        self._manager = page_info.manager
         ## owner of the page (fitting plugin)
-        self.event_owner= page_info.event_owner
-         ## current model
+        self.event_owner = page_info.event_owner
+        ## current model
         self.model = page_info.model
         ## data
@@ -430,5 +427,5 @@
         self.populate_box(dict=self.model_list_box)
         
-    def onContextMenu(self, event): 
+    def onContextMenu(self, event):
         """
         Retrieve the state selected state
@@ -440,19 +437,18 @@
         pos = self.ScreenToClient(pos)
        
-        self.PopupMenu(self.popUpMenu, pos) 
+        self.PopupMenu(self.popUpMenu, pos)
       
-        
     def onUndo(self, event):
         """
         Cancel the previous action
         """
-        event = PreviousStateEvent(page = self)
+        event = PreviousStateEvent(page=self)
         wx.PostEvent(self.parent, event)
         
     def onRedo(self, event):
         """
-        Restore the previous action cancelled 
-        """
-        event = NextStateEvent(page= self)
+        Restore the previous action cancelled
+        """
+        event = NextStateEvent(page=self)
         wx.PostEvent(self.parent, event)
     
@@ -461,5 +457,5 @@
         Create empty sizer for a panel
         """
-        self.vbox  = wx.BoxSizer(wx.VERTICAL)
+        self.vbox = wx.BoxSizer(wx.VERTICAL)
         self.sizer0 = wx.BoxSizer(wx.VERTICAL)
         self.sizer1 = wx.BoxSizer(wx.VERTICAL)
@@ -470,11 +466,11 @@
         self.sizer6 = wx.BoxSizer(wx.VERTICAL)
         
-        self.sizer0.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer1.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer2.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer3.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer4.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer5.SetMinSize((PANEL_WIDTH,-1))
-        self.sizer6.SetMinSize((PANEL_WIDTH,-1))
+        self.sizer0.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer1.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer2.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer3.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer4.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer5.SetMinSize((PANEL_WIDTH, -1))
+        self.sizer6.SetMinSize((PANEL_WIDTH, -1))
         
         self.vbox.Add(self.sizer0)
@@ -491,10 +487,10 @@
         """
         self.vbox.Layout()
-        self.vbox.Fit(self) 
+        self.vbox.Fit(self)
         self.SetSizer(self.vbox)
         self.Centre()
  
-    def set_owner(self,owner):
-        """ 
+    def set_owner(self, owner):
+        """
         set owner of fitpage
         
@@ -502,5 +498,5 @@
         
         """
-        self.event_owner = owner    
+        self.event_owner = owner
         self.state.event_owner = owner
         
@@ -512,13 +508,13 @@
     def get_data(self):
         """
-        return the current data 
-        """
-        return self.data  
+        return the current data
+        """
+        return self.data
     
     def get_data_list(self):
         """
-        return the current data 
-        """
-        return self.data_list  
+        return the current data
+        """
+        return self.data_list
     
     def set_manager(self, manager):
@@ -529,5 +525,5 @@
         
         """
-        self._manager = manager  
+        self._manager = manager
         self.state.manager = manager
         
@@ -543,7 +539,7 @@
         self.initialize_combox()
         
-    def initialize_combox(self): 
-        """
-        put default value in the combobox 
+    def initialize_combox(self):
+        """
+        put default value in the combobox
         """  
         ## fill combox box
@@ -568,5 +564,5 @@
                 self.text2.Show()
                 self.structurebox.Enable()
-                self.text2.Enable()            
+                self.text2.Enable()
                 
     def set_dispers_sizer(self):
@@ -575,6 +571,6 @@
         """
         self.sizer4.Clear(True)
-        name="Polydispersity and Orientational Distribution"
-        box_description= wx.StaticBox(self, -1,name)
+        name = "Polydispersity and Orientational Distribution"
+        box_description = wx.StaticBox(self, -1, name)
         box_description.SetForegroundColour(wx.BLUE)
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
@@ -585,13 +581,13 @@
         # best size for MAC and PC
         if ON_MAC:
-            size_q = (30, 20)      
+            size_q = (30, 20)
         else:
-            size_q = (20, 15)    
-        self.disp_help_bt = wx.Button(self,wx.NewId(),'?', 
-                                      style = wx.BU_EXACTFIT,
+            size_q = (20, 15)
+        self.disp_help_bt = wx.Button(self, wx.NewId(), '?',
+                                      style=wx.BU_EXACTFIT,
                                       size=size_q)
-        self.disp_help_bt.Bind(wx.EVT_BUTTON, 
-                        self.on_pd_help_clicked,id= self.disp_help_bt.GetId())
-        self.disp_help_bt.SetToolTipString("Helps for Polydispersion.")       
+        self.disp_help_bt.Bind(wx.EVT_BUTTON,
+                        self.on_pd_help_clicked, id=self.disp_help_bt.GetId())
+        self.disp_help_bt.SetToolTipString("Helps for Polydispersion.")
         
         self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
@@ -602,23 +598,22 @@
         self.disable_disp.SetValue(True)
         sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_dispersion.Add((20,20))
-        name=""#Polydispersity and \nOrientational Distribution "
-        sizer_dispersion.Add(wx.StaticText(self,-1,name))
-        sizer_dispersion.Add(self.enable_disp )
-        sizer_dispersion.Add((20,20))
-        sizer_dispersion.Add(self.disable_disp )
-        sizer_dispersion.Add((25,20))
+        sizer_dispersion.Add((20, 20))
+        name = ""  # Polydispersity and \nOrientational Distribution "
+        sizer_dispersion.Add(wx.StaticText(self, -1, name))
+        sizer_dispersion.Add(self.enable_disp)
+        sizer_dispersion.Add((20, 20))
+        sizer_dispersion.Add(self.disable_disp)
+        sizer_dispersion.Add((25, 20))
         sizer_dispersion.Add(self.disp_help_bt)
         
-        ## fill a sizer for dispersion         
-        boxsizer1.Add( sizer_dispersion,0,
-                wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5)
-        #boxsizer1.Add( (10,10) )
-        #boxsizer1.Add( sizer_select_dispers )
-        self.sizer4_4 = wx.GridBagSizer(6,5)
-
-        boxsizer1.Add( self.sizer4_4  )
+        ## fill a sizer for dispersion
+        boxsizer1.Add(sizer_dispersion, 0,
+                wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE,
+                border=5)
+        self.sizer4_4 = wx.GridBagSizer(6, 5)
+
+        boxsizer1.Add(self.sizer4_4)
         #-----------------------------------------------------
-        self.sizer4.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
+        self.sizer4.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10)
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -627,8 +622,7 @@
         self.Refresh()
         ## saving the state of enable dispersity button
-        self.state.enable_disp= self.enable_disp.GetValue()
-        self.state.disable_disp= self.disable_disp.GetValue()
+        self.state.enable_disp = self.enable_disp.GetValue()
+        self.state.disable_disp = self.disable_disp.GetValue()
         self.SetupScrolling()
-
     
     def onResetModel(self, event):
@@ -637,7 +631,7 @@
         """
         menu = event.GetEventObject()
-        ## post help message for the selected model 
+        ## post help message for the selected model
         msg = menu.GetHelpString(event.GetId())
-        msg +=" reloaded"
+        msg += " reloaded"
         wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         self.Show(False)
@@ -650,5 +644,5 @@
             ## reset state of checkbox,textcrtl  and  regular parameters value
             
-            self.reset_page(previous_state)   
+            self.reset_page(previous_state)
         self.state.m_name = self.m_name
         self.Show(True)
@@ -657,5 +651,5 @@
         """
         Report the current fit results
-        """   
+        """
         # Get plot image from plotpanel
         images, canvases = self.get_images()
@@ -663,14 +657,13 @@
         self.state.report(images, canvases)
         
-         
-    def on_save(self, event):   
+    def on_save(self, event):
         """
         Save the current state into file
-        """  
+        """
         self.save_current_state()
         new_state = self.state.clone()
         # Ask the user the location of the file to write to.
         path = None
-        if self.parent !=  None:
+        if self.parent != None:
             self._default_save_location = \
                         self.parent.parent._default_save_location
@@ -691,5 +684,5 @@
         #the manager write the state into file
         self._manager.save_fit_state(filepath=fName, fitstate=new_state)
-        return new_state  
+        return new_state
     
     def on_copy(self, event):
@@ -702,7 +695,4 @@
         wx.CallAfter(self.get_copy)
         
-        # messages depending on the flag
-        #self._copy_info(None)
-        
     def on_paste(self, event):
         """
@@ -711,6 +701,6 @@
         if event != None:
             event.Skip()
-        # It seems MAC needs wxCallAfter for the setvalues 
-        # for multiple textctrl items, otherwise it tends to crash once a while.
+        # It seems MAC needs wxCallAfter for the setvalues
+        # for multiple textctrl items, otherwise it tends to crash once a while
         wx.CallAfter(self.get_paste)
         # messages depending on the flag
@@ -735,6 +725,6 @@
             infor = "error"
         # inform msg to wx
-        wx.PostEvent( self.parent.parent, 
-                      StatusEvent(status= msg, info=infor))
+        wx.PostEvent(self.parent.parent,
+                    StatusEvent(status=msg, info=infor))
         
     def _get_time_stamp(self):
@@ -742,8 +732,9 @@
         return time and date stings
         """
-        # date and time 
-        year, month, day,hour,minute,second,tda,ty,tm_isdst= time.localtime()
-        current_time= str(hour)+":"+str(minute)+":"+str(second)
-        current_date= str( month)+"/"+str(day)+"/"+str(year)
+        # date and time
+        year, month, day, hour, minute, second, tda, ty, tm_isdst \
+            = time.localtime()
+        current_time = str(hour) + ":" + str(minute) + ":" + str(second)
+        current_date = str(month) + "/" + str(day) + "/" + str(year)
         return current_time, current_date
       
@@ -752,8 +743,8 @@
         save history of the data and model
         """
-        if self.model==None:
-            msg="Can not bookmark; Please select Data and Model first..."
+        if self.model == None:
+            msg = "Can not bookmark; Please select Data and Model first..."
             wx.MessageBox(msg, 'Info')
-            return 
+            return
         self.save_current_state()
         new_state = self.state.clone()
@@ -761,23 +752,25 @@
         self.number_saved_state += 1
         current_time, current_date = self._get_time_stamp()
-        #name= self.model.name+"[%g]"%self.number_saved_state 
-        name = "Fitting: %g]" % self.number_saved_state 
-        name += self.model.__class__.__name__ 
+        #name= self.model.name+"[%g]"%self.number_saved_state
+        name = "Fitting: %g]" % self.number_saved_state
+        name += self.model.__class__.__name__
         name += "bookmarked at %s on %s" % (current_time, current_date)
-        self.saved_states[name]= new_state
+        self.saved_states[name] = new_state
         
         ## Add item in the context menu
-        msg =  "Model saved at %s on %s"%(current_time, current_date)
-         ## post help message for the selected model 
-        msg +=" Saved! right click on this page to retrieve this model"
-        wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+        msg = "Model saved at %s on %s" % (current_time, current_date)
+        ## post help message for the selected model
+        msg += " Saved! right click on this page to retrieve this model"
+        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         
         id = wx.NewId()
-        self.popUpMenu.Append(id,name,str(msg))
+        self.popUpMenu.Append(id, name, str(msg))
         wx.EVT_MENU(self, id, self.onResetModel)
-        wx.PostEvent(self.parent.parent, 
-                     AppendBookmarkEvent(title=name, 
-                                         hint=str(msg), handler=self._back_to_bookmark))
-    def _back_to_bookmark(self, event): 
+        wx.PostEvent(self.parent.parent,
+                     AppendBookmarkEvent(title=name,
+                                         hint=str(msg),
+                                         handler=self._back_to_bookmark))
+    
+    def _back_to_bookmark(self, event):
         """
         Back to bookmark
@@ -786,6 +779,4 @@
         self.onResetModel(event)
         self._draw_model()
-        #self.save_current_state()
-        
         
     def old_on_bookmark(self, event):
@@ -793,19 +784,19 @@
         save history of the data and model
         """
-        if self.model==None:
-            msg="Can not bookmark; Please select Data and Model first..."
+        if self.model == None:
+            msg = "Can not bookmark; Please select Data and Model first..."
             wx.MessageBox(msg, 'Info')
-            return 
-        if hasattr(self,"enable_disp"):
+            return
+        if hasattr(self, "enable_disp"):
             self.state.enable_disp = copy.deepcopy(self.enable_disp.GetValue())
         if hasattr(self, "disp_box"):
             self.state.disp_box = copy.deepcopy(self.disp_box.GetSelection())
 
-        self.state.model.name= self.model.name
+        self.state.model.name = self.model.name
         
         #Remember fit engine_type for fit panel
-        if self.engine_type == None: 
+        if self.engine_type == None:
             self.engine_type = "scipy"
-        if self._manager !=None:
+        if self._manager != None:
             self._manager._on_change_engine(engine=self.engine_type)
         
@@ -818,25 +809,25 @@
         ##Add model state on context menu
         self.number_saved_state += 1
-        #name= self.model.name+"[%g]"%self.number_saved_state 
-        name= self.model.__class__.__name__+"[%g]"%self.number_saved_state 
-        self.saved_states[name]= new_state
+        name = self.model.__class__.__name__ + "[%g]" % self.number_saved_state
+        self.saved_states[name] = new_state
         
         ## Add item in the context menu
         
-        year, month, day,hour,minute,second,tda,ty,tm_isdst= time.localtime()
-        my_time= str(hour)+" : "+str(minute)+" : "+str(second)+" "
-        date= str( month)+"|"+str(day)+"|"+str(year)
-        msg=  "Model saved at %s on %s"%(my_time, date)
-         ## post help message for the selected model 
-        msg +=" Saved! right click on this page to retrieve this model"
-        wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+        year, month, day, hour, minute, second, tda, ty, tm_isdst \
+            = time.localtime()
+        my_time = str(hour) + " : " + str(minute) + " : " + str(second) + " "
+        date = str(month) + "|" + str(day) + "|" + str(year)
+        msg = "Model saved at %s on %s" % (my_time, date)
+        ## post help message for the selected model
+        msg += " Saved! right click on this page to retrieve this model"
+        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         
         id = wx.NewId()
-        self.popUpMenu.Append(id,name,str(msg))
+        self.popUpMenu.Append(id, name, str(msg))
         wx.EVT_MENU(self, id, self.onResetModel)
         
     def onSetFocus(self, evt):
         """
-        highlight the current textcrtl and hide the error text control shown 
+        highlight the current textcrtl and hide the error text control shown
         after fitting
         """
@@ -851,7 +842,7 @@
         """
         try:
-            if path==None:
-                wx.PostEvent(self.parent.parent, StatusEvent(status=\
-                            " Selected Distribution was not loaded: %s"%path))
+            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')
@@ -860,5 +851,5 @@
             
             angles = []
-            weights=[]
+            weights = []
             for line in lines:
                 toks = line.split()
@@ -873,5 +864,5 @@
             return numpy.array(angles), numpy.array(weights)
         except:
-            raise 
+            raise
 
     def createMemento(self):
@@ -880,5 +871,4 @@
         """
         return self.state.clone()
-    
     
     def save_current_state(self):
@@ -888,7 +878,7 @@
         self.state.engine_type = copy.deepcopy(self.engine_type)
         ## save model option
-        if self.model!= None:
-            self.disp_list= self.model.getDispParamList()
-            self.state.disp_list= copy.deepcopy(self.disp_list)
+        if self.model != None:
+            self.disp_list = self.model.getDispParamList()
+            self.state.disp_list = copy.deepcopy(self.disp_list)
             self.state.model = self.model.clone()
         #save radiobutton state for model selection
@@ -898,12 +888,12 @@
         self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
         #model combobox
-        self.state.structurebox = self.structurebox.GetLabel()#.GetSelection()
-        self.state.formfactorbox = self.formfactorbox.GetLabel()#.GetSelection()
+        self.state.structurebox = self.structurebox.GetLabel()
+        self.state.formfactorbox = self.formfactorbox.GetLabel()
         
         self.state.enable2D = copy.deepcopy(self.enable2D)
-        self.state.values= copy.deepcopy(self.values)
-        self.state.weights = copy.deepcopy( self.weights)
-        ## save data    
-        self.state.data= copy.deepcopy(self.data)
+        self.state.values = copy.deepcopy(self.values)
+        self.state.weights = copy.deepcopy(self.weights)
+        ## save data
+        self.state.data = copy.deepcopy(self.data)
         self.state.qmax_x = self.qmax_x
         self.state.qmin_x = self.qmin_x
@@ -914,10 +904,10 @@
         self.state.dq_l = self.dq_l
         self.state.dq_r = self.dq_r
-        if hasattr(self,"enable_disp"):
-            self.state.enable_disp= self.enable_disp.GetValue()
+        if hasattr(self, "enable_disp"):
+            self.state.enable_disp = self.enable_disp.GetValue()
             self.state.disable_disp = self.disable_disp.GetValue()
             
         self.state.smearer = copy.deepcopy(self.current_smearer)
-        if hasattr(self,"enable_smearer"):
+        if hasattr(self, "enable_smearer"):
             self.state.enable_smearer = \
                                 copy.deepcopy(self.enable_smearer.GetValue())
@@ -927,11 +917,10 @@
         self.state.pinhole_smearer = \
                                 copy.deepcopy(self.pinhole_smearer.GetValue())
-        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue())  
+        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue())
                   
-        if len(self._disp_obj_dict)>0:
-            for k , v in self._disp_obj_dict.iteritems():
-                self.state._disp_obj_dict[k]= v
-                        
-            
+        if len(self._disp_obj_dict) > 0:
+            for k, v in self._disp_obj_dict.iteritems():
+                self.state._disp_obj_dict[k] = v
+
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
@@ -946,7 +935,6 @@
         self.state.str_parameters = []
 
-        
         ## save checkbutton state and txtcrtl values
-        self._copy_parameters_state(self.str_parameters, 
+        self._copy_parameters_state(self.str_parameters,
                                     self.state.str_parameters)
         self._copy_parameters_state(self.orientation_params,
@@ -967,7 +955,7 @@
         """
         ## save model option
-        if self.model!= None:
-            self.disp_list= self.model.getDispParamList()
-            self.state.disp_list= copy.deepcopy(self.disp_list)
+        if self.model != None:
+            self.disp_list = self.model.getDispParamList()
+            self.state.disp_list = copy.deepcopy(self.disp_list)
             self.state.model = self.model.clone()
         if hasattr(self, "engine_type"):
@@ -975,15 +963,15 @@
             
         self.state.enable2D = copy.deepcopy(self.enable2D)
-        self.state.values= copy.deepcopy(self.values)
-        self.state.weights = copy.deepcopy( self.weights)
-        ## save data    
-        self.state.data= copy.deepcopy(self.data)
-        
-        if hasattr(self,"enable_disp"):
-            self.state.enable_disp= self.enable_disp.GetValue()
+        self.state.values = copy.deepcopy(self.values)
+        self.state.weights = copy.deepcopy(self.weights)
+        ## save data
+        self.state.data = copy.deepcopy(self.data)
+        
+        if hasattr(self, "enable_disp"):
+            self.state.enable_disp = self.enable_disp.GetValue()
             self.state.disable_disp = self.disable_disp.GetValue()
             
         self.state.smearer = copy.deepcopy(self.current_smearer)
-        if hasattr(self,"enable_smearer"):
+        if hasattr(self, "enable_smearer"):
             self.state.enable_smearer = \
                                 copy.deepcopy(self.enable_smearer.GetValue())
@@ -993,10 +981,10 @@
         self.state.pinhole_smearer = \
                                 copy.deepcopy(self.pinhole_smearer.GetValue())
-        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue())  
+        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue())
         self.state.dI_noweight = copy.deepcopy(self.dI_noweight.GetValue())
         self.state.dI_didata = copy.deepcopy(self.dI_didata.GetValue())
         self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue())
-        self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue())  
-        if hasattr(self,"disp_box"):
+        self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue())
+        if hasattr(self, "disp_box"):
             self.state.disp_box = self.disp_box.GetCurrentSelection()
 
@@ -1004,5 +992,5 @@
                 for k, v in self.disp_cb_dict.iteritems():
          
-                    if v == None :
+                    if v == None:
                         self.state.disp_cb_dict[k] = v
                     else:
@@ -1013,9 +1001,7 @@
            
             if len(self._disp_obj_dict) > 0:
-                for k , v in self._disp_obj_dict.iteritems():
-      
+                for k, v in self._disp_obj_dict.iteritems():
                     self.state._disp_obj_dict[k] = v
                         
-            
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
@@ -1034,10 +1020,8 @@
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
     
-          
-    def check_invalid_panel(self):  
+    def check_invalid_panel(self):
         """
         check if the user can already perform some action with this panel
-        """ 
-        flag = False
+        """
         if self.data is None:
             self.disable_smearer.SetValue(True)
@@ -1055,5 +1039,5 @@
       
         ## set the state of the radio box
-        self.shape_rbutton.SetValue(state.shape_rbutton )
+        self.shape_rbutton.SetValue(state.shape_rbutton)
         self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton)
         self.struct_rbutton.SetValue(state.struct_rbutton)
@@ -1092,5 +1076,5 @@
             self.multifactorbox.SetSelection(state.multi_factor)
             
-         ## reset state of checkbox,textcrtl  and  regular parameters value
+        ## reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
                                      state.orientation_params_disp)
@@ -1099,15 +1083,14 @@
         self._reset_parameters_state(self.str_parameters,
                                      state.str_parameters)
-        self._reset_parameters_state(self.parameters,state.parameters)
-         ## display dispersion info layer        
+        self._reset_parameters_state(self.parameters, state.parameters)
+        ## display dispersion info layer
         self.enable_disp.SetValue(state.enable_disp)
         self.disable_disp.SetValue(state.disable_disp)
         
         if hasattr(self, "disp_box"):
-            
-            self.disp_box.SetSelection(state.disp_box) 
-            n= self.disp_box.GetCurrentSelection()
-            dispersity= self.disp_box.GetClientData(n)
-            name = dispersity.__name__     
+            self.disp_box.SetSelection(state.disp_box)
+            n = self.disp_box.GetCurrentSelection()
+            dispersity = self.disp_box.GetClientData(n)
+            name = dispersity.__name__
 
             self._set_dipers_Param(event=None)
@@ -1117,5 +1100,5 @@
                 for item in self.disp_cb_dict.keys():
                     
-                    if hasattr(self.disp_cb_dict[item], "SetValue") :
+                    if hasattr(self.disp_cb_dict[item], "SetValue"):
                         self.disp_cb_dict[item].SetValue(\
                                                     state.disp_cb_dict[item])
@@ -1123,16 +1106,16 @@
                         from sans.models.dispersion_models import ArrayDispersion
                         disp_model = ArrayDispersion()
-                        if hasattr(state,"values")and\
+                        if hasattr(state, "values") and \
                                  self.disp_cb_dict[item].GetValue() == True:
-                            if len(state.values)>0:
-                                self.values=state.values
-                                self.weights=state.weights
+                            if len(state.values) > 0:
+                                self.values = state.values
+                                self.weights = state.weights
                                 disp_model.set_weights(self.values,
-                                                        state.weights)
+                                                       state.weights)
                             else:
                                 self._reset_dispersity()
                         
                         self._disp_obj_dict[item] = disp_model
-                        # Set the new model as the dispersion object 
+                        # Set the new model as the dispersion object
                         #for the selected parameter
                         self.model.set_dispersion(item, disp_model)
@@ -1145,16 +1128,16 @@
                 for item in keys:
                     if item in self.disp_list and \
-                        not self.model.details.has_key(item):
+                        not item in self.model.details:
                         self.model.details[item] = ["", None, None]
-                for k,v in self.state.disp_cb_dict.iteritems():
-                    self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
+                for k, v in self.state.disp_cb_dict.iteritems():
+                    self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
                     self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
-         ## smearing info  restore
+        ## smearing info  restore
         if hasattr(self, "enable_smearer"):
-            ## set smearing value whether or not the data 
+            ## set smearing value whether or not the data
             #contain the smearing info
             self.enable_smearer.SetValue(state.enable_smearer)
             self.disable_smearer.SetValue(state.disable_smearer)
-            self.onSmear(event=None)           
+            self.onSmear(event=None)
         self.pinhole_smearer.SetValue(state.pinhole_smearer)
         self.slit_smearer.SetValue(state.slit_smearer)
@@ -1166,14 +1149,16 @@
         
         ## we have two more options for smearing
-        if self.pinhole_smearer.GetValue(): self.onPinholeSmear(event=None)
-        elif self.slit_smearer.GetValue(): self.onSlitSmear(event=None)
+        if self.pinhole_smearer.GetValue():
+            self.onPinholeSmear(event=None)
+        elif self.slit_smearer.GetValue():
+            self.onSlitSmear(event=None)
        
         ## reset state of checkbox,textcrtl  and dispersity parameters value
-        self._reset_parameters_state(self.fittable_param,state.fittable_param)
-        self._reset_parameters_state(self.fixed_param,state.fixed_param)
+        self._reset_parameters_state(self.fittable_param, state.fittable_param)
+        self._reset_parameters_state(self.fixed_param, state.fixed_param)
         
         ## draw the model with previous parameters value
         self._onparamEnter_helper()
-        self.select_param(event=None) 
+        self.select_param(event=None)
         #Save state_fit
         self.save_current_state_fit()
@@ -1191,6 +1176,5 @@
         """
         if state == None:
-            #self._undo.Enable(False)
-            return 
+            return
         # set data, etc. from the state
         # reset page between theory and fitting from bookmarking
@@ -1200,6 +1184,4 @@
         data = state.data
 
-        #if data != None:
-        
         if data == None:
             data_min = state.qmin
@@ -1207,6 +1189,4 @@
             self.qmin_x = data_min
             self.qmax_x = data_max
-            #self.minimum_q.SetValue(str(data_min))
-            #self.maximum_q.SetValue(str(data_max))
             self.qmin.SetValue(str(data_min))
             self.qmax.SetValue(str(data_max))
@@ -1218,5 +1198,5 @@
             self.set_data(data)
             
-        self.enable2D= state.enable2D
+        self.enable2D = state.enable2D
         self.engine_type = state.engine_type
 
@@ -1225,5 +1205,5 @@
       
         ## set the state of the radio box
-        self.shape_rbutton.SetValue(state.shape_rbutton )
+        self.shape_rbutton.SetValue(state.shape_rbutton)
         self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton)
         self.struct_rbutton.SetValue(state.struct_rbutton)
@@ -1239,5 +1219,5 @@
             formfactor_pos = 0
             for ind_form in range(self.formfactorbox.GetCount()):
-                if self.formfactorbox.GetString(ind_form).count(state.formfactorcombobox)>0:
+                if self.formfactorbox.GetString(ind_form).count(state.formfactorcombobox) > 0:
                     formfactor_pos = int(ind_form)
                     break
@@ -1251,5 +1231,5 @@
             structfactor_pos = 0
             for ind_struct in range(self.structurebox.GetCount()):
-                if self.structurebox.GetString(ind_struct).count(state.structurecombobox)>0:
+                if self.structurebox.GetString(ind_struct).count(state.structurecombobox) > 0:
                     structfactor_pos = int(ind_struct)
                     break
@@ -1262,5 +1242,5 @@
         #reset the fitting engine type
         self.engine_type = state.engine_type
-        #draw the pnael according to the new model parameter 
+        #draw the pnael according to the new model parameter
         self._on_select_model(event=None)
             
@@ -1273,5 +1253,5 @@
         # else:
                 
-        if self._manager !=None and self.engine_type != None:
+        if self._manager != None and self.engine_type != None:
             self._manager._on_change_engine(engine=self.engine_type)
         ## set the select all check box to the a given state
@@ -1285,6 +1265,6 @@
         self._reset_parameters_state(self.str_parameters,
                                      state.str_parameters)
-        self._reset_parameters_state(self.parameters,state.parameters)    
-         ## display dispersion info layer        
+        self._reset_parameters_state(self.parameters, state.parameters)
+        ## display dispersion info layer
         self.enable_disp.SetValue(state.enable_disp)
         self.disable_disp.SetValue(state.disable_disp)
@@ -1294,13 +1274,13 @@
             self._set_dipers_Param(event=None)
             self._reset_page_disp_helper(state)
-        ##plotting range restore    
+        ##plotting range restore
         self._reset_plotting_range(state)
         ## smearing info  restore
         if hasattr(self, "enable_smearer"):
-            ## set smearing value whether or not the data 
+            ## set smearing value whether or not the data
             #contain the smearing info
             self.enable_smearer.SetValue(state.enable_smearer)
             self.disable_smearer.SetValue(state.disable_smearer)
-            self.onSmear(event=None)           
+            self.onSmear(event=None)
         self.pinhole_smearer.SetValue(state.pinhole_smearer)
         self.slit_smearer.SetValue(state.slit_smearer)
@@ -1318,10 +1298,12 @@
  
         ## we have two more options for smearing
-        if self.pinhole_smearer.GetValue(): self.onPinholeSmear(event=None)
-        elif self.slit_smearer.GetValue(): self.onSlitSmear(event=None)
+        if self.pinhole_smearer.GetValue():
+            self.onPinholeSmear(event=None)
+        elif self.slit_smearer.GetValue():
+            self.onSlitSmear(event=None)
         
         ## reset state of checkbox,textcrtl  and dispersity parameters value
-        self._reset_parameters_state(self.fittable_param,state.fittable_param)
-        self._reset_parameters_state(self.fixed_param,state.fixed_param)
+        self._reset_parameters_state(self.fittable_param, state.fittable_param)
+        self._reset_parameters_state(self.fixed_param, state.fixed_param)
         
         ## draw the model with previous parameters value
@@ -1333,5 +1315,5 @@
         
         ## set the value of the current state to the state given as parameter
-        self.state = state.clone() 
+        self.state = state.clone()
         self.state.m_name = self.m_name
     
@@ -1343,8 +1325,8 @@
         for item in keys:
             if item in self.disp_list and \
-                not self.model.details.has_key(item):
+                not item in self.model.details:
                 self.model.details[item] = ["", None, None]
         #for k,v in self.state.disp_cb_dict.iteritems():
-        self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
+        self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
         self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
         self.values = copy.deepcopy(state.values)
@@ -1355,5 +1337,5 @@
             # it will be sent as a string here, then converted to model object.
             if disp.__class__.__name__ == 'str':
-                com_str  = "from sans.models.dispersion_models "
+                com_str = "from sans.models.dispersion_models "
                 com_str += "import %s as disp_func"
                 exec com_str % disp
@@ -1362,8 +1344,8 @@
                 disp_model = disp
 
-            self._disp_obj_dict[key] = disp_model 
+            self._disp_obj_dict[key] = disp_model
             param_name = key.split('.')[0]
             # Try to set dispersion only when available
-            # for eg., pass the orient. angles for 1D Cal 
+            # for eg., pass the orient. angles for 1D Cal
             try:
                 self.model.set_dispersion(param_name, disp_model)
@@ -1376,8 +1358,8 @@
                 if list[1] == key and list[7] != None:
                     list[7].SetSelection(selection)
-                    # For the array disp_model, set the values and weights 
+                    # For the array disp_model, set the values and weights
                     if selection == 1:
-                        disp_model.set_weights(self.values[key], 
-                                              self.weights[key])
+                        disp_model.set_weights(self.values[key],
+                                               self.weights[key])
                         try:
                             # Diables all fittable params for array
@@ -1401,5 +1383,5 @@
         # Make sure the check box updated when all checked
         if self.cb1.GetValue():
-            self.select_all_param(None)        
+            self.select_all_param(None)
       
     def _selectDlg(self):
@@ -1407,10 +1389,9 @@
         open a dialog file to selected the customized dispersity 
         """
-        import os
-        if self.parent !=  None:
+        if self.parent != None:
             self._default_save_location = \
                         self.parent.parent._default_save_location
         dlg = wx.FileDialog(self, "Choose a weight file",
-                                self._default_save_location , "", 
+                                self._default_save_location, "",
                                 "*.*", wx.OPEN)
         path = None
@@ -1436,8 +1417,6 @@
         Reset the plotting range to a given state
         """
-        # if self.check_invalid_panel():
-        #    return
         self.qmin.SetValue(str(state.qmin))
-        self.qmax.SetValue(str(state.qmax)) 
+        self.qmax.SetValue(str(state.qmax))
 
     def _save_typeOfmodel(self):
@@ -1449,26 +1428,25 @@
         self.state.struct_rbutton = self.struct_rbutton.GetValue()
         self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
-        self.state.structurebox= self.structurebox.GetLabel()#.GetCurrentSelection()
-        self.state.formfactorbox = self.formfactorbox.GetLabel()#.GetCurrentSelection()
+        self.state.structurebox = self.structurebox.GetLabel()
+        self.state.formfactorbox = self.formfactorbox.GetLabel()
        
-        #self._undo.Enable(True)
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
         
-    def _save_plotting_range(self ):
-        """
-        save the state of plotting range 
+    def _save_plotting_range(self):
+        """
+        save the state of plotting range
         """
         self.state.qmin = self.qmin_x
-        self.state.qmax = self.qmax_x 
+        self.state.qmax = self.qmax_x
         self.state.npts = self.npts_x
             
     def _onparamEnter_helper(self):
         """
-        check if values entered by the user are changed and valid to replot 
+        check if values entered by the user are changed and valid to replot
         model
         """
-        # Flag to register when a parameter has changed.   
+        # Flag to register when a parameter has changed.
         is_modified = False
         self.fitrange = True
@@ -1478,5 +1456,5 @@
         if self.data.__class__.__name__ == "Data2D":
             is_2Ddata = True
-        if self.model !=None:
+        if self.model != None:
             try:
                 is_modified = self._check_value_enter(self.fittable_param,
@@ -1485,10 +1463,10 @@
                                                       is_modified)
                 is_modified = self._check_value_enter(self.parameters,
-                                                      is_modified) 
+                                                      is_modified)
             except:
                 pass
 
             # Here we should check whether the boundaries have been modified.
-            # If qmin and qmax have been modified, update qmin and qmax and 
+            # If qmin and qmax have been modified, update qmin and qmax and
             # set the is_modified flag to True
             if self._validate_qrange(self.qmin, self.qmax):
@@ -1503,9 +1481,9 @@
             
                 if is_2Ddata:
-                    # set mask   
+                    # set mask
                     is_modified = self._validate_Npts()
                     
             else:
-                self.fitrange = False    
+                self.fitrange = False
                 
             if not self.data.is_data:
@@ -1515,16 +1493,15 @@
             if not self.fitrange:
                 #self.btFit.Disable()
-                if is_2Ddata: self.btEditMask.Disable()
+                if is_2Ddata:
+                    self.btEditMask.Disable()
             else:
-                #self.btFit.Enable(True)
-                if is_2Ddata  and self.data.is_data and not self.batch_on: 
+                if is_2Ddata and self.data.is_data and not self.batch_on:
                     self.btEditMask.Enable(True)
             if is_modified and self.fitrange:
-                #if self.data == None:
                 # Theory case: need to get npts value to draw
                 self.npts_x = float(self.Npts_total.GetValue())
                 self.create_default_data()
-                self.state_change= True
-                self._draw_model() 
+                self.state_change = True
+                self._draw_model()
                 self.Refresh()
         return is_modified
@@ -1544,16 +1521,16 @@
         ##So make sure that update param values on_Fit.
         #self._undo.Enable(True)
-        if self.model !=None:   
+        if self.model != None:
             if self.Npts_total.GetValue() != self.Npts_fit.GetValue():
                 if not self.data.is_data:
                     self._manager.page_finder[self.uid].set_fit_data(data=\
-                                                                    [self.data])      
+                                                                [self.data])
             ##Check the values
-            self._check_value_enter( self.fittable_param ,is_modified)
-            self._check_value_enter( self.fixed_param ,is_modified)
-            self._check_value_enter( self.parameters ,is_modified)
+            self._check_value_enter(self.fittable_param, is_modified)
+            self._check_value_enter(self.fixed_param, is_modified)
+            self._check_value_enter(self.parameters, is_modified)
 
             # If qmin and qmax have been modified, update qmin and qmax and 
-             # Here we should check whether the boundaries have been modified.
+            # 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
@@ -1567,8 +1544,8 @@
                     self.qmax_x = tempmax
                 if tempmax == tempmin:
-                    flag = False    
+                    flag = False
                 temp_smearer = None
                 if not self.disable_smearer.GetValue():
-                    temp_smearer= self.current_smearer
+                    temp_smearer = self.current_smearer
                     if self.slit_smearer.GetValue():
                         flag = self.update_slit_smear()
@@ -1579,6 +1556,6 @@
                                                   uid=self.uid,
                                                   fid=self.data.id,
-                                                     qmin=float(self.qmin_x),
-                                                      qmax=float(self.qmax_x),
+                                                  qmin=float(self.qmin_x),
+                                                  qmax=float(self.qmax_x),
                             enable_smearer=not self.disable_smearer.GetValue(),
                                                       draw=False)
@@ -1586,13 +1563,13 @@
                     self._manager.set_smearer(smearer=temp_smearer,
                                               qmin=float(self.qmin_x),
-                                              uid=self.uid, 
+                                              uid=self.uid,
                                               fid=self.data.id,
-                                                 qmax= float(self.qmax_x),
+                                              qmax=float(self.qmax_x),
                             enable_smearer=not self.disable_smearer.GetValue(),
                                                  draw=False)
                     if self.data != None:
-                        index_data = ((self.qmin_x <= self.data.x)&\
+                        index_data = ((self.qmin_x <= self.data.x) & \
                                       (self.data.x <= self.qmax_x))
-                        val = str(len(self.data.x[index_data==True]))
+                        val = str(len(self.data.x[index_data == True]))
                         self.Npts_fit.SetValue(val)
                     else:
@@ -1605,19 +1582,18 @@
                     flag = True
                 if self._is_2D():
-                    # only 2D case set mask  
+                    # only 2D case set mask
                     flag = self._validate_Npts()
                     if not flag:
                         return flag
-            else: flag = False
-        else: 
+            else:
+                flag = False
+        else:
             flag = False
 
-        #For invalid q range, disable the mask editor and fit button, vs.    
+        #For invalid q range, disable the mask editor and fit button, vs.
         if not self.fitrange:
-            #self.btFit.Disable()
             if self._is_2D():
                 self.btEditMask.Disable()
         else:
-            #self.btFit.Enable(True)
             if self._is_2D() and  self.data.is_data and not self.batch_on:
                 self.btEditMask.Enable(True)
@@ -1633,5 +1609,5 @@
             pass
    
-        return flag                           
+        return flag
                
     def _is_modified(self, is_modified):
@@ -1647,5 +1623,5 @@
         if len(statelist) == 0 or len(listtorestore) == 0:
             return
-        if len(statelist) !=  len(listtorestore):
+        if len(statelist) != len(listtorestore):
             return
 
@@ -1654,13 +1630,13 @@
             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])
-            if item_page[2]!=None:
+            if item_page[2] != None:
                 item_page[2].SetValue(item_page_info[2])
                 if item_page[2].__class__.__name__ == "ComboBox":
-                   if self.model.fun_list.has_key(item_page_info[2]):
-                       fun_val = self.model.fun_list[item_page_info[2]]
-                       self.model.setParam(item_page_info[1],fun_val)
-            if item_page[3]!=None:
+                    if item_page_info[2] in self.model.fun_list:
+                        fun_val = self.model.fun_list[item_page_info[2]]
+                        self.model.setParam(item_page_info[1], fun_val)
+            if item_page[3] != None:
                 ## show or hide text +/-
                 if item_page_info[2]:
@@ -1668,5 +1644,5 @@
                 else:
                     item_page[3].Hide()
-            if item_page[4]!=None:
+            if item_page[4] != None:
                 ## show of hide the text crtl for fitting error
                 if item_page_info[4][0]:
@@ -1675,14 +1651,13 @@
                 else:
                     item_page[3].Hide()
-            if item_page[5]!=None:
+            if item_page[5] != None:
                 ## show of hide the text crtl for fitting error
                 item_page[5].Show(item_page_info[5][0])
                 item_page[5].SetValue(item_page_info[5][1])
                 
-            if item_page[6]!=None:
+            if item_page[6] != None:
                 ## show of hide the text crtl for fitting error
                 item_page[6].Show(item_page_info[6][0])
                 item_page[6].SetValue(item_page_info[6][1])
-
                     
     def _reset_strparam_state(self, listtorestore, statelist):
@@ -1700,5 +1675,5 @@
             ##change the state of the check box for simple parameters
             
-            if item_page[0] != None:   
+            if item_page[0] != None:
                 item_page[0].SetValue(format_number(item_page_info[0], True))
 
@@ -1707,5 +1682,5 @@
                 value = item_page_info[2]
                 selection = value
-                if self.model.fun_list.has_key(value):
+                if value in self.model.fun_list:
                     selection = self.model.fun_list[value]
                 item_page[2].SetValue(selection)
@@ -1714,5 +1689,5 @@
     def _copy_parameters_state(self, listtocopy, statelist):
         """
-        copy the state of button 
+        copy the state of button
         
         :param listtocopy: the list of check button to copy
@@ -1720,5 +1695,5 @@
         
         """
-        if len(listtocopy)==0:
+        if len(listtocopy) == 0:
             return
        
@@ -1726,16 +1701,16 @@
   
             checkbox_state = None
-            if item[0]!= None:
-                checkbox_state= item[0].GetValue()
+            if item[0] != None:
+                checkbox_state = item[0].GetValue()
             parameter_name = item[1]
             parameter_value = None
-            if item[2]!=None:
+            if item[2] != None:
                 parameter_value = item[2].GetValue()
             static_text = None
-            if item[3]!=None:
+            if item[3] != None:
                 static_text = item[3].IsShown()
             error_value = None
             error_state = None
-            if item[4]!= None:
+            if item[4] != None:
                 error_value = item[4].GetValue()
                 error_state = item[4].IsShown()
@@ -1743,5 +1718,5 @@
             min_value = None
             min_state = None
-            if item[5]!= None:
+            if item[5] != None:
                 min_value = item[5].GetValue()
                 min_state = item[5].IsShown()
@@ -1749,15 +1724,15 @@
             max_value = None
             max_state = None
-            if item[6]!= None:
+            if item[6] != None:
                 max_value = item[6].GetValue()
                 max_state = item[6].IsShown()
-            unit=None
-            if item[7]!=None:
+            unit = None
+            if item[7] != None:
                 unit = item[7].GetLabel()
                
             statelist.append([checkbox_state, parameter_name, parameter_value,
-                              static_text ,[error_state, error_value],
-                                [min_state, min_value],
-                                [max_state, max_value], unit])
+                              static_text, [error_state, error_value],
+                              [min_state, min_value],
+                              [max_state, max_value], unit])
            
     def _set_model_sizer_selection(self, model):
@@ -1767,5 +1742,5 @@
         if model == None:
             return
-        if hasattr(model ,"s_model"):
+        if hasattr(model, "s_model"):
             
             class_name = model.s_model.__class__
@@ -1775,5 +1750,5 @@
                 (class_name in self.model_list_box["Structure Factors"]):
                 self.structurebox.Show()
-                self.text2.Show()                
+                self.text2.Show()
                 self.structurebox.Enable()
                 self.text2.Enable()
@@ -1782,9 +1757,9 @@
                 
                 for i in range(len(items)):
-                    if items[i]== str(name):
+                    if items[i] == str(name):
                         self.structurebox.SetSelection(i)
                         break
                     
-        if hasattr(model ,"p_model"):
+        if hasattr(model, "p_model"):
             class_name = model.p_model.__class__
             name = model.p_model.name
@@ -1792,12 +1767,14 @@
             
             for k, list in self.model_list_box.iteritems():
-                if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]:
+                if k in["P(Q)*S(Q)", "Shapes"] and \
+                    class_name in self.model_list_box["Shapes"]:
                     self.shape_rbutton.SetValue(True)
                     ## fill the form factor list with new model
-                    self._populate_box(self.formfactorbox,self.model_list_box["Shapes"])
+                    self._populate_box(self.formfactorbox,
+                                       self.model_list_box["Shapes"])
                     items = self.formfactorbox.GetItems()
                     ## set comboxbox to the selected item
                     for i in range(len(items)):
-                        if items[i]== str(name):
+                        if items[i] == str(name):
                             self.formfactorbox.SetSelection(i)
                             break
@@ -1806,6 +1783,6 @@
                     self.shape_indep_rbutton.SetValue(True)
                 elif k == "Structure Factors":
-                     self.struct_rbutton.SetValue(True)
-                elif  k == "Multi-Functions":
+                    self.struct_rbutton.SetValue(True)
+                elif k == "Multi-Functions":
                     continue
                 else:
@@ -1818,10 +1795,9 @@
                     ## set comboxbox to the selected item
                     for i in range(len(items)):
-                        if items[i]== str(name):
+                        if items[i] == str(name):
                             self.formfactorbox.SetSelection(i)
                             break
                     break
         else:
-
             ## Select the model from the menu
             class_name = model.__class__
@@ -1830,6 +1806,7 @@
             items = self.formfactorbox.GetItems()
     
-            for k, list in self.model_list_box.iteritems():          
-                if k in["P(Q)*S(Q)","Shapes" ] and class_name in self.model_list_box["Shapes"]:
+            for k, list in self.model_list_box.iteritems():
+                if k in["P(Q)*S(Q)", "Shapes"] and \
+                    class_name in self.model_list_box["Shapes"]:
                     if class_name in self.model_list_box["P(Q)*S(Q)"]:
                         self.structurebox.Show()
@@ -1847,9 +1824,10 @@
                     self.shape_rbutton.SetValue(True)
                     ## fill the form factor list with new model
-                    self._populate_box(self.formfactorbox,self.model_list_box["Shapes"])
+                    self._populate_box(self.formfactorbox,
+                                       self.model_list_box["Shapes"])
                     items = self.formfactorbox.GetItems()
                     ## set comboxbox to the selected item
                     for i in range(len(items)):
-                        if items[i]== str(name):
+                        if items[i] == str(name):
                             self.formfactorbox.SetSelection(i)
                             break
@@ -1859,5 +1837,5 @@
                 elif k == "Structure Factors":
                     self.struct_rbutton.SetValue(True)
-                elif  k == "Multi-Functions":
+                elif k == "Multi-Functions":
                     continue
                 else:
@@ -1866,5 +1844,5 @@
                     self.structurebox.SetSelection(0)
                     self.structurebox.Disable()
-                    self.text2.Disable()                    
+                    self.text2.Disable()
                     ## fill the form factor list with new model
                     self._populate_box(self.formfactorbox, list)
@@ -1872,5 +1850,5 @@
                     ## set comboxbox to the selected item
                     for i in range(len(items)):
-                        if items[i]== str(name):
+                        if items[i] == str(name):
                             self.formfactorbox.SetSelection(i)
                             break
@@ -1897,9 +1875,9 @@
         #if self.check_invalid_panel():
         #    return
-        if self.model !=None:
-            temp_smear=None
+        if self.model != None:
+            temp_smear = None
             if hasattr(self, "enable_smearer"):
                 if not self.disable_smearer.GetValue():
-                    temp_smear= self.current_smearer
+                    temp_smear = self.current_smearer
             # compute weight for the current data
             from .utils import get_weight
@@ -1908,12 +1886,12 @@
             toggle_mode_on = self.model_view.IsEnabled()
             is_2d = self._is_2D()
-            self._manager.draw_model(self.model, 
+            self._manager.draw_model(self.model,
                                     data=self.data,
-                                    smearer= temp_smear,
-                                    qmin=float(self.qmin_x), 
+                                    smearer=temp_smear,
+                                    qmin=float(self.qmin_x),
                                     qmax=float(self.qmax_x),
                                     page_id=self.uid,
-                                    toggle_mode_on=toggle_mode_on, 
-                                    state = self.state,
+                                    toggle_mode_on=toggle_mode_on,
+                                    state=self.state,
                                     enable2D=is_2d,
                                     update_chisqr=update_chisqr,
@@ -1921,5 +1899,4 @@
                                     weight=weight)
         
-       
     def _on_show_sld(self, event=None):
         """
@@ -1927,5 +1904,5 @@
         """
         # get profile data
-        x,y=self.model.getProfile()
+        x, y = self.model.getProfile()
 
         from danse.common.plottools import Data1D
@@ -1933,11 +1910,11 @@
         from sans.guiframe.local_perspectives.plotting.profile_dialog \
         import SLDPanel
-        sld_data = Data1D(x,y)
+        sld_data = Data1D(x, y)
         sld_data.name = 'SLD'
         sld_data.axes = self.sld_axes
-        self.panel = SLDPanel(self, data=sld_data, axes =self.sld_axes,id =-1)
-        self.panel.ShowModal()    
-        
-    def _set_multfactor_combobox(self, multiplicity=10):   
+        self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id=-1)
+        self.panel.ShowModal()
+        
+    def _set_multfactor_combobox(self, multiplicity=10):
         """
         Set comboBox for muitfactor of CoreMultiShellModel
@@ -1945,30 +1922,28 @@
         """
         # build content of the combobox
-        for idx in range(0,multiplicity):
-            self.multifactorbox.Append(str(idx),int(idx))
-            #self.multifactorbox.SetSelection(1) 
+        for idx in range(0, multiplicity):
+            self.multifactorbox.Append(str(idx), int(idx))
         self._hide_multfactor_combobox()
         
-    def _show_multfactor_combobox(self):   
+    def _show_multfactor_combobox(self):
         """
         Show the comboBox of muitfactor of CoreMultiShellModel
-        """ 
+        """
         if not self.mutifactor_text.IsShown():
             self.mutifactor_text.Show(True)
             self.mutifactor_text1.Show(True)
         if not self.multifactorbox.IsShown():
-            self.multifactorbox.Show(True)  
+            self.multifactorbox.Show(True)
              
-    def _hide_multfactor_combobox(self):   
+    def _hide_multfactor_combobox(self):
         """
         Hide the comboBox of muitfactor of CoreMultiShellModel
-        """ 
+        """
         if self.mutifactor_text.IsShown():
             self.mutifactor_text.Hide()
             self.mutifactor_text1.Hide()
         if self.multifactorbox.IsShown():
-            self.multifactorbox.Hide()   
-
-        
+            self.multifactorbox.Hide()
+
     def _show_combox_helper(self):
         """
@@ -1980,5 +1955,6 @@
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,self.model_list_box["Shapes"])
+            self._populate_box(self.formfactorbox,
+                               self.model_list_box["Shapes"])
         if self.shape_indep_rbutton.GetValue():
             ##fill the combobox with shape independent  factor list
@@ -1986,6 +1962,6 @@
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
-                                self.model_list_box["Shape-Independent"])
+            self._populate_box(self.formfactorbox,
+                             self.model_list_box["Shape-Independent"])
         if self.struct_rbutton.GetValue():
             ##fill the combobox with structure factor list
@@ -1993,12 +1969,12 @@
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
-                                self.model_list_box["Structure Factors"])
+            self._populate_box(self.formfactorbox,
+                               self.model_list_box["Structure Factors"])
         if self.plugin_rbutton.GetValue():
             ##fill the combobox with form factor list
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
-                                self.model_list_box["Customized Models"])
+            self._populate_box(self.formfactorbox,
+                               self.model_list_box["Customized Models"])
         
     def _show_combox(self, event=None):
@@ -2006,7 +1982,4 @@
         Show combox box associate with type of model selected
         """
-        #if self.check_invalid_panel():
-        #    self.shape_rbutton.SetValue(True)
-        #    return
         self.Show(False)
         self._show_combox_helper()
@@ -2028,15 +2001,15 @@
         mlist = []
         for models in list:
-            model= models()
+            model = models()
             name = model.__class__.__name__
-            if models.__name__!="NoStructure":
+            if models.__name__ != "NoStructure":
                 if hasattr(model, "name"):
                     name = model.name
-                mlist.append( (name, models) )
+                mlist.append((name, models))
                 
         # Sort the models
         mlist_sorted = mlist
         for item in mlist_sorted:
-            combobox.Append(item[0],item[1])
+            combobox.Append(item[0], item[1])
         return 0
     
@@ -2066,17 +2039,17 @@
                 else:
                     tcrtl.SetBackgroundColour("pink")
-                    msg = "Model Error:wrong value entered : %s" % sys.exc_value
+                    msg = "Model Error:wrong value entered: %s" % sys.exc_value
                     wx.PostEvent(self.parent, StatusEvent(status=msg))
-                    return 
+                    return
             except:
                 tcrtl.SetBackgroundColour("pink")
-                msg = "Model Error:wrong value entered : %s" % sys.exc_value
+                msg = "Model Error:wrong value entered: %s" % sys.exc_value
                 wx.PostEvent(self.parent, StatusEvent(status=msg))
-                return 
+                return
             #Check if # of points for theory model are valid(>0).
             if self.npts != None:
                 if check_float(self.npts):
                     temp_npts = float(self.npts.GetValue())
-                    if temp_npts !=  self.num_points:
+                    if temp_npts != self.num_points:
                         self.num_points = temp_npts
                         is_modified = True
@@ -2085,8 +2058,7 @@
                     wx.PostEvent(self.parent, StatusEvent(status=msg))
         else:
-           tcrtl.SetBackgroundColour("pink")
-           msg = "Model Error:wrong value entered!!!"
-           wx.PostEvent(self.parent, StatusEvent(status=msg))
-        #self._undo.Enable(True)
+            tcrtl.SetBackgroundColour("pink")
+            msg = "Model Error:wrong value entered!!!"
+            wx.PostEvent(self.parent, StatusEvent(status=msg))
         self.save_current_state()
         event = PageInfoEvent(page=self)
@@ -2103,11 +2075,11 @@
         """
         
-        tcrtl= event.GetEventObject()
+        tcrtl = event.GetEventObject()
         #Clear msg if previously shown.
-        msg= ""
-        wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+        msg = ""
+        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         # Flag to register when a parameter has changed.
         is_modified = False
-        if tcrtl.GetValue().lstrip().rstrip()!="":
+        if tcrtl.GetValue().lstrip().rstrip() != "":
             try:
                 value = float(tcrtl.GetValue())
@@ -2124,36 +2096,35 @@
                 else:
                     tcrtl.SetBackgroundColour("pink")
-                    msg= "Model Error:wrong value entered : %s"% sys.exc_value
-                    wx.PostEvent(self._manager.parent, StatusEvent(status = msg ))
-                    return  
+                    msg = "Model Error:wrong value entered: %s" % sys.exc_value
+                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
+                    return
             except:
                 tcrtl.SetBackgroundColour("pink")
-                msg= "Model Error:wrong value entered : %s"% sys.exc_value
-                wx.PostEvent(self._manager.parent, StatusEvent(status = msg ))
-                return 
+                msg = "Model Error:wrong value entered: %s" % sys.exc_value
+                wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
+                return
             #Check if # of points for theory model are valid(>0).
-            if self.Npts_total.IsEditable() :
+            if self.Npts_total.IsEditable():
                 if check_float(self.Npts_total):
                     temp_npts = float(self.Npts_total.GetValue())
-                    if temp_npts !=  self.num_points:
+                    if temp_npts != self.num_points:
                         self.num_points = temp_npts
                         is_modified = True
                 else:
-                    msg= "Cannot Plot :No npts in that Qrange!!!  "
-                    wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+                    msg = "Cannot Plot :No npts in that Qrange!!!  "
+                    wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         else:
-           tcrtl.SetBackgroundColour("pink")
-           msg = "Model Error:wrong value entered!!!"
-           wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
-        #self._undo.Enable(True)
+            tcrtl.SetBackgroundColour("pink")
+            msg = "Model Error:wrong value entered!!!"
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         self.save_current_state()
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
-        self.state_change= False
+        self.state_change = False
         #Draw the model for a different range
         self.create_default_data()
         self._draw_model()
                    
-    def _on_select_model_helper(self): 
+    def _on_select_model_helper(self):
         """
         call back for model selection
@@ -2161,5 +2132,5 @@
         ## reset dictionary containing reference to dispersion
         self._disp_obj_dict = {}
-        self.disp_cb_dict ={}
+        self.disp_cb_dict = {}
         self.temp_multi_functional = False
         f_id = self.formfactorbox.GetCurrentSelection()
@@ -2171,5 +2142,5 @@
         if not form_factor in  self.model_list_box["multiplication"]:
             self.structurebox.Hide()
-            self.text2.Hide()           
+            self.text2.Hide()
             self.structurebox.Disable()
             self.structurebox.SetSelection(0)
@@ -2181,24 +2152,23 @@
             self.text2.Enable()
             
-        if form_factor != None:    
-            # set multifactor for Mutifunctional models    
+        if form_factor != None:
+            # set multifactor for Mutifunctional models
             if form_factor().__class__ in self.model_list_box["Multi-Functions"]:
                 m_id = self.multifactorbox.GetCurrentSelection()
                 multiplicity = form_factor().multiplicity_info[0]
                 self.multifactorbox.Clear()
-                #self.mutifactor_text.SetLabel(form_factor().details[])
                 self._set_multfactor_combobox(multiplicity)
                 self._show_multfactor_combobox()
-                #ToDo:  this info should be called directly from the model 
-                text = form_factor().multiplicity_info[1]#'No. of Shells: '
-
-                #self.mutifactor_text.Clear()
+                #ToDo:  this info should be called directly from the model
+                text = form_factor().multiplicity_info[1]  # 'No. of Shells: '
+
                 self.mutifactor_text.SetLabel(text)
-                if m_id > multiplicity -1:
+                if m_id > multiplicity - 1:
                     # default value
                     m_id = 1
                     
                 self.multi_factor = self.multifactorbox.GetClientData(m_id)
-                if self.multi_factor == None: self.multi_factor =0
+                if self.multi_factor == None:
+                    self.multi_factor = 0
                 form_factor = form_factor(int(self.multi_factor))
                 self.multifactorbox.SetSelection(m_id)
@@ -2223,12 +2193,12 @@
             self._hide_multfactor_combobox()
             self.show_sld_button.Hide()
-            self.multi_factor = None  
+            self.multi_factor = None
               
         s_id = self.structurebox.GetCurrentSelection()
-        struct_factor = self.structurebox.GetClientData( s_id )
-        
-        if  struct_factor !=None:
+        struct_factor = self.structurebox.GetClientData(s_id)
+        
+        if  struct_factor != None:
             from sans.models.MultiplicationModel import MultiplicationModel
-            self.model= MultiplicationModel(form_factor,struct_factor())
+            self.model = MultiplicationModel(form_factor, struct_factor())
             # multifunctional form factor
             if len(form_factor.non_fittable) > 0:
@@ -2236,5 +2206,5 @@
         else:
             if form_factor != None:
-                self.model= form_factor
+                self.model = form_factor
             else:
                 self.model = None
@@ -2242,12 +2212,12 @@
             
         ## post state to fit panel
-        self.state.parameters =[]
-        self.state.model =self.model
+        self.state.parameters = []
+        self.state.model = self.model
         self.state.qmin = self.qmin_x
         self.state.multi_factor = self.multi_factor
-        self.disp_list =self.model.getDispParamList()
+        self.disp_list = self.model.getDispParamList()
         self.state.disp_list = self.disp_list
         self.on_set_focus(None)
-        self.Layout()     
+        self.Layout()
         
     def _validate_qrange(self, qmin_ctrl, qmax_ctrl):
@@ -2259,5 +2229,5 @@
         :param qmax_ctrl: text control for Qmax
         
-        :return: True is the Q range is value, False otherwise 
+        :return: True is the Q range is value, False otherwise
         
         """
@@ -2270,5 +2240,5 @@
             qmax = float(qmax_ctrl.GetValue())
             if qmin < qmax:
-                #Make sure to set both colours white.  
+                #Make sure to set both colours white.
                 qmin_ctrl.SetBackgroundColour(wx.WHITE)
                 qmin_ctrl.Refresh()
@@ -2280,10 +2250,10 @@
                 qmax_ctrl.SetBackgroundColour("pink")
                 qmax_ctrl.Refresh()
-                msg= "Invalid Q range: Q min must be smaller than Q max"
-                wx.PostEvent(self.parent.parent, StatusEvent(status = msg))
+                msg = "Invalid Q range: Q min must be smaller than Q max"
+                wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
                 return False
         return True
     
-    def _validate_Npts(self):  
+    def _validate_Npts(self):
         """
         Validate the number of points for fitting is more than 10 points.
@@ -2297,10 +2267,10 @@
         for data in self.data_list:
             # q value from qx and qy
-            radius= numpy.sqrt( data.qx_data * data.qx_data + 
-                                data.qy_data * data.qy_data )
+            radius = numpy.sqrt(data.qx_data * data.qx_data +
+                                data.qy_data * data.qy_data)
             #get unmasked index
             index_data = (float(self.qmin.GetValue()) <= radius) & \
                             (radius <= float(self.qmax.GetValue()))
-            index_data = (index_data) & (data.mask) 
+            index_data = (index_data) & (data.mask)
             index_data = (index_data) & (numpy.isfinite(data.data))
 
@@ -2311,15 +2281,15 @@
                 self.qmax.SetBackgroundColour("pink")
                 self.qmax.Refresh()
-                msg= "Npts of Data Error :No or too little npts of %s."% data.name
-                wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+                msg = "Npts of Data Error :No or too little npts of %s." % data.name
+                wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
                 self.fitrange = False
                 flag = False
             else:
-                self.Npts_fit.SetValue(str(len(index_data[index_data==True])))
+                self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
                 self.fitrange = True
             
         return flag
 
-    def _validate_Npts_1D(self):  
+    def _validate_Npts_1D(self):
         """
         Validate the number of points for fitting is more than 5 points.
@@ -2333,5 +2303,5 @@
         for data in self.data_list:
             # q value from qx and qy
-            radius= data.x
+            radius = data.x
             #get unmasked index
             index_data = (float(self.qmin.GetValue()) <= radius) & \
@@ -2345,15 +2315,13 @@
                 self.qmax.SetBackgroundColour("pink")
                 self.qmax.Refresh()
-                msg= "Npts of Data Error :No or too little npts of %s."% data.name
-                wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+                msg = "Npts of Data Error :No or too little npts of %s." % data.name
+                wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
                 self.fitrange = False
                 flag = False
             else:
-                self.Npts_fit.SetValue(str(len(index_data[index_data==True])))
+                self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
                 self.fitrange = True
             
         return flag
-
-
     
     def _check_value_enter(self, list, modified):
@@ -2362,16 +2330,16 @@
         :Note: each item of the list should be as follow:
             item=[check button state, parameter's name,
-                paramater's value, string="+/-", 
-                parameter's error of fit, 
-                parameter's minimum value, 
-                parrameter's maximum value , 
+                paramater's value, string="+/-",
+                parameter's error of fit,
+                parameter's minimum value,
+                parrameter's maximum value ,
                 parameter's units]
-        """  
-        is_modified =  modified
-        if len(list)==0:
+        """
+        is_modified = modified
+        if len(list) == 0:
             return is_modified
         for item in list:
             #skip angle parameters for 1D
-            if not self.enable2D:#self.data.__class__.__name__ !="Data2D":
+            if not self.enable2D:
                 if item in self.orientation_params:
                     continue
@@ -2379,17 +2347,16 @@
             name = str(item[1])
             
-            if string.find(name,".npts") ==-1 and \
-                                        string.find(name,".nsigmas")==-1:      
-                ## check model parameters range             
-                param_min= None
-                param_max= None
+            if string.find(name, ".npts") == -1 and \
+                                        string.find(name, ".nsigmas") == -1:
+                ## check model parameters range
+                param_min = None
+                param_max = None
                
                 ## check minimun value
-                if item[5]!= None and item[5]!= "":
-                    if item[5].GetValue().lstrip().rstrip()!="":
+                if item[5] != None and item[5] != "":
+                    if item[5].GetValue().lstrip().rstrip() != "":
                         try:
-                            
                             param_min = float(item[5].GetValue())
-                            if not self._validate_qrange(item[5],item[2]):
+                            if not self._validate_qrange(item[5], item[2]):
                                 if numpy.isfinite(param_min):
                                     item[2].SetValue(format_number(param_min))
@@ -2400,16 +2367,16 @@
                         except:
                             msg = "Wrong Fit parameter range entered "
-                            wx.PostEvent(self.parent.parent, 
-                                         StatusEvent(status = msg))
+                            wx.PostEvent(self.parent.parent,
+                                         StatusEvent(status=msg))
                             raise ValueError, msg
                         is_modified = True
                 ## check maximum value
-                if item[6]!= None and item[6]!= "":
-                    if item[6].GetValue().lstrip().rstrip()!="":
-                        try:                          
+                if item[6] != None and item[6] != "":
+                    if item[6].GetValue().lstrip().rstrip() != "":
+                        try:
                             param_max = float(item[6].GetValue())
-                            if not self._validate_qrange(item[2],item[6]):
+                            if not self._validate_qrange(item[2], item[6]):
                                 if numpy.isfinite(param_max):
-                                    item[2].SetValue(format_number(param_max))  
+                                    item[2].SetValue(format_number(param_max))
                             
                             item[6].SetBackgroundColour(wx.WHITE)
@@ -2417,28 +2384,26 @@
                         except:
                             msg = "Wrong Fit parameter range entered "
-                            wx.PostEvent(self.parent.parent, 
-                                         StatusEvent(status = msg))
+                            wx.PostEvent(self.parent.parent,
+                                         StatusEvent(status=msg))
                             raise ValueError, msg
                         is_modified = True
                 
-
-                if param_min != None and param_max !=None:
+                if param_min != None and param_max != None:
                     if not self._validate_qrange(item[5], item[6]):
-                        msg= "Wrong Fit range entered for parameter "
-                        msg+= "name %s of model %s "%(name, self.model.name)
-                        wx.PostEvent(self.parent.parent, 
-                                     StatusEvent(status = msg))
+                        msg = "Wrong Fit range entered for parameter "
+                        msg += "name %s of model %s " % (name, self.model.name)
+                        wx.PostEvent(self.parent.parent,
+                                     StatusEvent(status=msg))
                 
-                if name in self.model.details.keys():   
+                if name in self.model.details.keys():
                         self.model.details[name][1:3] = param_min, param_max
                         is_modified = True
-              
                 else:
-                        self.model.details [name] = ["", param_min, param_max] 
+                        self.model.details[name] = ["", param_min, param_max]
                         is_modified = True
-            try:   
+            try:
                 # Check if the textctr is enabled
                 if item[2].IsEnabled():
-                    value= float(item[2].GetValue())
+                    value = float(item[2].GetValue())
                     item[2].SetBackgroundColour("white")
                     # If the value of the parameter has changed,
@@ -2447,35 +2412,31 @@
                                                 numpy.isfinite(value):
                         self.model.setParam(name, value)
-                        
             except:
                 item[2].SetBackgroundColour("pink")
                 msg = "Wrong Fit parameter value entered "
-                wx.PostEvent(self.parent.parent, StatusEvent(status = msg))
+                wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
                 
-        return is_modified 
-        
- 
+        return is_modified
+        
     def _set_dipers_Param(self, event):
         """
         respond to self.enable_disp and self.disable_disp radio box.
-        The dispersity object is reset inside the model into Gaussian. 
-        When the user select yes , this method display a combo box for more selection
-        when the user selects No,the combo box disappears.
+        The dispersity object is reset inside the model into Gaussian.
+        When the user select yes , this method display a combo box for
+        more selection when the user selects No,the combo box disappears.
         Redraw the model with the default dispersity (Gaussian)
         """
-        #if self.check_invalid_panel():
-        #    return 
         ## On selction if no model exists.
-        if self.model ==None:
+        if self.model == None:
             self.disable_disp.SetValue(True)
-            msg="Please select a Model first..."
+            msg = "Please select a Model first..."
             wx.MessageBox(msg, 'Info')
-            wx.PostEvent(self._manager.parent, StatusEvent(status=\
-                            "Polydispersion: %s"%msg))
+            wx.PostEvent(self._manager.parent,
+                         StatusEvent(status="Polydispersion: %s" % msg))
             return
 
         self._reset_dispersity()
     
-        if self.model ==None:
+        if self.model == None:
             self.model_disp.Hide()
             self.sizer4_4.Clear(True)
@@ -2485,19 +2446,18 @@
             ## layout for model containing no dispersity parameters
             
-            self.disp_list= self.model.getDispParamList()
+            self.disp_list = self.model.getDispParamList()
              
-            if len(self.disp_list)==0 and len(self.disp_cb_dict)==0:
-                self._layout_sizer_noDipers()  
+            if len(self.disp_list) == 0 and len(self.disp_cb_dict) == 0:
+                self._layout_sizer_noDipers()
             else:
-                ## set gaussian sizer 
+                ## set gaussian sizer
                 self._on_select_Disp(event=None)
         else:
             self.sizer4_4.Clear(True)
             
-        ## post state to fit panel 
+        ## post state to fit panel
         self.save_current_state()
-        if event !=None:
-            #self._undo.Enable(True)
-            event = PageInfoEvent(page = self)
+        if event != None:
+            event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, event)
         #draw the model with the current dispersity
@@ -2506,23 +2466,21 @@
         self.sizer5.Layout()
         self.Layout()
-        self.Refresh()      
+        self.Refresh()
           
-        
     def _layout_sizer_noDipers(self):
         """
         Draw a sizer with no dispersity info
         """
-        ix=0
-        iy=1
-        self.fittable_param=[]
-        self.fixed_param=[]
-        self.orientation_params_disp=[]
+        ix = 0
+        iy = 1
+        self.fittable_param = []
+        self.fixed_param = []
+        self.orientation_params_disp = []
         
         self.sizer4_4.Clear(True)
         text = "No polydispersity available for this model"
-        text = "No polydispersity available for this model"
         model_disp = wx.StaticText(self, -1, text)
-        self.sizer4_4.Add(model_disp,( iy, ix),(1,1),  
-                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
+        self.sizer4_4.Add(model_disp, (iy, ix), (1, 1),
+                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10)
         self.sizer4_4.Layout()
         self.sizer4.Layout()
@@ -2532,5 +2490,5 @@
         put gaussian dispersity into current model
         """
-        if len(self.param_toFit)>0:
+        if len(self.param_toFit) > 0:
             for item in self.fittable_param:
                 if item in self.param_toFit:
@@ -2541,26 +2499,27 @@
                     self.param_toFit.remove(item)
          
-        self.fittable_param=[]
-        self.fixed_param=[]
-        self.orientation_params_disp=[]
-        self.values={}
-        self.weights={}
+        self.fittable_param = []
+        self.fixed_param = []
+        self.orientation_params_disp = []
+        self.values = {}
+        self.weights = {}
       
-        from sans.models.dispersion_models import GaussianDispersion, ArrayDispersion
-        if len(self.disp_cb_dict)==0:
+        from sans.models.dispersion_models import GaussianDispersion
+        if len(self.disp_cb_dict) == 0:
             self.save_current_state()
             self.sizer4_4.Clear(True)
             self.Layout()
- 
-            return 
-        if (len(self.disp_cb_dict)>0) :
+            return
+        if (len(self.disp_cb_dict) > 0):
             for p in self.disp_cb_dict:
-                # The parameter was un-selected. Go back to Gaussian model (with 0 pts)                    
+                # The parameter was un-selected.
+                # Go back to Gaussian model (with 0 pts)
                 disp_model = GaussianDispersion()
                
                 self._disp_obj_dict[p] = disp_model
-                # Set the new model as the dispersion object for the selected parameter
+                # Set the new model as the dispersion object
+                # for the selected parameter
                 try:
-                   self.model.set_dispersion(p, disp_model)
+                    self.model.set_dispersion(p, disp_model)
                 except:
 
@@ -2569,8 +2528,8 @@
         ## save state into
         self.save_current_state()
-        self.Layout()  
+        self.Layout()
         self.Refresh()
                   
-    def _on_select_Disp(self,event):
+    def _on_select_Disp(self, event):
         """
         allow selecting different dispersion
@@ -2580,7 +2539,7 @@
 
         ## Redraw the model
-        self._draw_model() 
+        self._draw_model()
         #self._undo.Enable(True)
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
         
@@ -2589,9 +2548,9 @@
         self.SetupScrolling()
     
-    def _on_disp_func(self, event=None): 
+    def _on_disp_func(self, event=None):
         """
         Select a distribution function for the polydispersion
         
-        :Param event: ComboBox event 
+        :Param event: ComboBox event
         """
         # get ready for new event
@@ -2599,13 +2558,13 @@
             event.Skip()
         # Get event object
-        disp_box =  event.GetEventObject() 
+        disp_box = event.GetEventObject()
 
         # Try to select a Distr. function
-        try:   
+        try:
             disp_box.SetBackgroundColour("white")
             selection = disp_box.GetCurrentSelection()
             param_name = disp_box.Name.split('.')[0]
             disp_name = disp_box.GetValue()
-            dispersity= disp_box.GetClientData(selection)
+            dispersity = disp_box.GetClientData(selection)
     
             #disp_model =  GaussianDispersion()
@@ -2617,6 +2576,6 @@
             # Check Disp. function whether or not it is 'array'
             if disp_name.lower() == "array":
-                value2= ""
-                value3= ""
+                value2 = ""
+                value3 = ""
                 value1 = self._set_array_disp(name=name1, disp=disp_model)
             else:
@@ -2625,13 +2584,13 @@
                 self._disp_obj_dict[name1] = disp_model
                 self.model.set_dispersion(param_name, disp_model)
-                self.state._disp_obj_dict[name1]= disp_model
+                self.state._disp_obj_dict[name1] = disp_model
  
-                value1= str(format_number(self.model.getParam(name1), True))
-                value2= str(format_number(self.model.getParam(name2)))
-                value3= str(format_number(self.model.getParam(name3)))
+                value1 = str(format_number(self.model.getParam(name1), True))
+                value2 = str(format_number(self.model.getParam(name2)))
+                value3 = str(format_number(self.model.getParam(name3)))
             # Reset fittable polydispersin parameter value
             for item in self.fittable_param:
-                 if item[1] == name1:
-                    item[2].SetValue(value1) 
+                if item[1] == name1:
+                    item[2].SetValue(value1)
                     item[5].SetValue("")
                     item[6].SetValue("")
@@ -2649,5 +2608,5 @@
                         item[2].Enable()
                         item[5].Enable()
-                        item[6].Enable()                       
+                        item[6].Enable()
                     break
             # Reset fixed polydispersion params
@@ -2661,5 +2620,5 @@
                         item[2].Enable()
                 if item[1] == name3:
-                    item[2].SetValue(value3) 
+                    item[2].SetValue(value3)
                     # Disable Nsigs for array
                     if disp_name.lower() == "array":
@@ -2674,5 +2633,5 @@
 
             # update params
-            self._update_paramv_on_fit() 
+            self._update_paramv_on_fit()
             # draw
             self._draw_model()
@@ -2686,7 +2645,6 @@
             # Focus on Fit button so that users can see the pinky box
             self.btFit.SetFocus()
-            wx.PostEvent(self.parent.parent, 
+            wx.PostEvent(self.parent.parent,
                          StatusEvent(status=msg, info="error"))
-        
         
     def _set_array_disp(self, name=None, disp=None):
@@ -2697,5 +2655,5 @@
         :param disp: the polydisperion object
         """
-        # The user wants this parameter to be averaged. 
+        # The user wants this parameter to be averaged.
         # Pop up the file selection dialog.
         path = self._selectDlg()
@@ -2713,10 +2671,10 @@
                              self._default_save_location
 
-        basename  = os.path.basename(path)
-        values,weights = self.read_file(path)
+        basename = os.path.basename(path)
+        values, weights = self.read_file(path)
         
         # If any of the two arrays is empty, notify the user that we won't
         # proceed
-        if len(self.param_toFit)>0:
+        if len(self.param_toFit) > 0:
             if name in self.param_toFit:
                 self.param_toFit.remove(name)
@@ -2724,10 +2682,10 @@
         # Tell the user that we are about to apply the distribution
         msg = "Applying loaded %s distribution: %s" % (name, path)
-        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))  
+        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         self._set_array_disp_model(name=name, disp=disp,
                                     values=values, weights=weights)
         return basename
     
-    def _set_array_disp_model(self, name=None, disp=None, 
+    def _set_array_disp_model(self, name=None, disp=None,
                               values=[], weights=[]):
         """
@@ -2740,5 +2698,5 @@
         self._disp_obj_dict[name] = disp
         self.model.set_dispersion(name.split('.')[0], disp)
-        self.state._disp_obj_dict[name]= disp
+        self.state._disp_obj_dict[name] = disp
         self.values[name] = values
         self.weights[name] = weights
@@ -2751,23 +2709,22 @@
         self.state.weights = copy.deepcopy(self.weights)
 
-        # Set the new model as the dispersion object for the 
+        # Set the new model as the dispersion object for the
         #selected parameter
         #self.model.set_dispersion(p, disp_model)
-        # Store a reference to the weights in the model object 
+        # Store a reference to the weights in the model object
         #so that
         # it's not lost when we use the model within another thread.
         #TODO: total hack - fix this
-        self.state.model= self.model.clone()
+        self.state.model = self.model.clone()
         self.model._persistency_dict[name.split('.')[0]] = \
                                         [values, weights]
         self.state.model._persistency_dict[name.split('.')[0]] = \
-                                        [values,weights]
+                                        [values, weights]
                                         
-
-    def _del_array_values(self, name=None):  
+    def _del_array_values(self, name=None):
         """
         Reset array dispersion
         
-        :param name: name of the parameter for the dispersion to be set 
+        :param name: name of the parameter for the dispersion to be set
         """
         # Try to delete values and weight of the names array dic if exists
@@ -2778,5 +2735,5 @@
             del self.state.values[name]
             del self.state.weights[name]
-            del self.model._persistency_dict[name.split('.')[0]] 
+            del self.model._persistency_dict[name.split('.')[0]]
             del self.state.model._persistency_dict[name.split('.')[0]]
         except:
@@ -2792,24 +2749,25 @@
         self._sleep4sec()
         self.Layout()
-        return 
+        return
     
     def _sleep4sec(self):
         """
             sleep for 1 sec only applied on Mac
-            Note: This 1sec helps for Mac not to crash on self.:ayout after self._draw_model
+            Note: This 1sec helps for Mac not to crash on self.
+            Layout after self._draw_model
         """
         if ON_MAC == True:
             time.sleep(1)
             
-    def _find_polyfunc_selection(self, disp_func = None):
-        """
-        FInd Comboox selection from disp_func 
+    def _find_polyfunc_selection(self, disp_func=None):
+        """
+        FInd Comboox selection from disp_func
         
         :param disp_function: dispersion distr. function
         """
         # List of the poly_model name in the combobox
-        list = ["RectangleDispersion", "ArrayDispersion", 
-                    "LogNormalDispersion", "GaussianDispersion", 
-                    "SchulzDispersion"]
+        list = ["RectangleDispersion", "ArrayDispersion",
+                "LogNormalDispersion", "GaussianDispersion",
+                "SchulzDispersion"]
 
         # Find the selection
@@ -2818,16 +2776,14 @@
             return selection
         except:
-             return 3
+            return 3
                             
-    def on_reset_clicked(self,event):
+    def on_reset_clicked(self, event):
         """
         On 'Reset' button  for Q range clicked
         """
         flag = True
-        #if self.check_invalid_panel():
-        #    return
         ##For 3 different cases: Data2D, Data1D, and theory
         if self.model == None:
-            msg="Please select a model first..."
+            msg = "Please select a model first..."
             wx.MessageBox(msg, 'Info')
             flag = False
@@ -2835,7 +2791,7 @@
             
         elif self.data.__class__.__name__ == "Data2D":
-            data_min= 0
-            x= max(math.fabs(self.data.xmin), math.fabs(self.data.xmax)) 
-            y= max(math.fabs(self.data.ymin), math.fabs(self.data.ymax))
+            data_min = 0
+            x = max(math.fabs(self.data.xmin), math.fabs(self.data.xmax))
+            y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax))
             self.qmin_x = data_min
             self.qmax_x = math.sqrt(x*x + y*y)
@@ -2843,6 +2799,6 @@
             # check smearing
             if not self.disable_smearer.GetValue():
-                temp_smearer= self.current_smearer
-                ## set smearing value whether or not the data contain the smearing info
+                ## set smearing value whether or
+                # not the data contain the smearing info
                 if self.pinhole_smearer.GetValue():
                     flag = self.update_pinhole_smear()
@@ -2853,5 +2809,5 @@
             self.qmin_x = _QMIN_DEFAULT
             self.qmax_x = _QMAX_DEFAULT
-            self.num_points = _NPTS_DEFAULT            
+            self.num_points = _NPTS_DEFAULT
             self.state.npts = self.num_points
             
@@ -2861,6 +2817,6 @@
             # check smearing
             if not self.disable_smearer.GetValue():
-                temp_smearer= self.current_smearer
-                ## set smearing value whether or not the data contain the smearing info
+                ## set smearing value whether or
+                # not the data contain the smearing info
                 if self.slit_smearer.GetValue():
                     flag = self.update_slit_smear()
@@ -2873,6 +2829,6 @@
             
         if flag == False:
-            msg= "Cannot Plot :Must enter a number!!!  "
-            wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))
+            msg = "Cannot Plot :Must enter a number!!!  "
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
         else:
             # set relative text ctrs.
@@ -2880,6 +2836,7 @@
             self.qmax.SetValue(str(self.qmax_x))
             self.set_npts2fit()
-            # At this point, some button and variables satatus (disabled?) should be checked 
-            # such as color that should be reset to white in case that it was pink.
+            # At this point, some button and variables satatus (disabled?)
+            # should be checked such as color that should be reset to
+            # white in case that it was pink.
             self._onparamEnter_helper()
 
@@ -2890,6 +2847,4 @@
         #reset the q range values
         self._reset_plotting_range(self.state)
-        #self.compute_chisqr(smearer=self.current_smearer)
-        #Re draw plot
         self._draw_model()
         
@@ -2908,27 +2863,20 @@
         # loops through the panels [dic]
         for item1, item2 in gui_manager.plot_panels.iteritems():
-             data_title = self.data.group_id
-             data_name = str(self.data.name).split(" [")[0]
+            data_title = self.data.group_id
             # try to get all plots belonging to this control panel
-             try:
-                 title = ''
-                 # check titles (main plot) 
-                 if hasattr(item2,"data2D"):
-                     title = item2.data2D.title
-                 # and data_names (model plot[2D], and residuals)
-                 if item2.group_id == data_title or \
+            try:
+                if item2.group_id == data_title or \
                         item2.group_id.count("res" + str(self.graph_id)) or \
                         item2.group_id.count(str(self.uid)) > 0:
-                     #panel = gui_manager._mgr.GetPane(item2.window_name)
-                     # append to the list
-                     graphs.append(item2.figure) 
-                     canvases.append(item2.canvas)     
-             except:
-                 # Not for control panels
-                 pass
+                    # append to the list
+                    graphs.append(item2.figure)
+                    canvases.append(item2.canvas)
+            except:
+                # Not for control panels
+                pass
         # return the list of graphs
         return graphs, canvases
 
-    def on_model_help_clicked(self,event):
+    def on_model_help_clicked(self, event):
         """
         on 'More details' button
@@ -2939,28 +2887,25 @@
         # Get models help model_function path
         path = get_data_path(media='media')
-        model_path = os.path.join(path,"model_functions.html")
+        model_path = os.path.join(path, "model_functions.html")
         if self.model == None:
             name = 'FuncHelp'
         else:
             name = self.formfactorbox.GetValue()
-            #name = self.model.__class__.__name__
-        frame = HelpWindow(None, -1,  pageToOpen=model_path)    
+        frame = HelpWindow(None, -1, pageToOpen=model_path)
         if frame.rhelp.HasAnchor(name):
             frame.Show(True)
             frame.rhelp.ScrollToAnchor(name)
         else:
-           #msg= "Sorry, no information is available for this model"
-           #wx.PostEvent(self.parent.parent, StatusEvent(status = msg ))  
-           if self.model != None:
-               frame.Destroy() 
-               msg = 'Model description:\n'
-               if str(self.model.description).rstrip().lstrip() == '':
-                   msg += "Sorry, no information is available for this model.\n"
-               else:
-                   msg += self.model.description + '\n'
-               info = "Info"
-               wx.MessageBox(msg, info)
-           else:
-               frame.Show(True)   
+            if self.model != None:
+                frame.Destroy()
+                msg = 'Model description:\n'
+                if str(self.model.description).rstrip().lstrip() == '':
+                    msg += "Sorry, no information is available for this model."
+                else:
+                    msg += self.model.description + '\n'
+                info = "Info"
+                wx.MessageBox(msg, info)
+            else:
+                frame.Show(True)
     
     def on_pd_help_clicked(self, event):
@@ -2969,11 +2914,11 @@
         """
         from help_panel import  HelpWindow
-        import sans.models as models 
+        import sans.models as models
         
         # Get models help model_function path
         path = models.get_data_path(media='media')
-        pd_path = os.path.join(path,"pd_help.html")
-
-        frame = HelpWindow(None, -1,  pageToOpen=pd_path)    
+        pd_path = os.path.join(path, "pd_help.html")
+
+        frame = HelpWindow(None, -1, pageToOpen=pd_path)
         frame.Show(True)
         
@@ -2997,34 +2942,34 @@
         Get copy params to clipboard
         """
-        content = self.get_copy_params() 
+        content = self.get_copy_params()
         flag = self.set_clipboard(content)
-        self._copy_info(flag) 
-        return flag 
-            
-    def get_copy_params(self): 
+        self._copy_info(flag)
+        return flag
+            
+    def get_copy_params(self):
         """
         Get the string copies of the param names and values in the tap
-        """  
+        """
         content = 'sansview_parameter_values:'
-        # Do it if params exist        
-        if  self.parameters !=[]:
-            
-            # go through the parameters 
-            string = self._get_copy_helper(self.parameters, 
+        # Do it if params exist
+        if  self.parameters != []:
+            
+            # go through the parameters
+            string = self._get_copy_helper(self.parameters,
                                            self.orientation_params)
             content += string
             
             # go through the fittables
-            string = self._get_copy_helper(self.fittable_param, 
+            string = self._get_copy_helper(self.fittable_param,
                                            self.orientation_params_disp)
             content += string
 
             # go through the fixed params
-            string = self._get_copy_helper(self.fixed_param, 
+            string = self._get_copy_helper(self.fixed_param,
                                            self.orientation_params_disp)
             content += string
                 
             # go through the str params
-            string = self._get_copy_helper(self.str_parameters, 
+            string = self._get_copy_helper(self.str_parameters,
                                            self.orientation_params)
             content += string
@@ -3033,8 +2978,8 @@
             return False
     
-    def set_clipboard(self, content=None): 
+    def set_clipboard(self, content=None):
         """
         Put the string to the clipboard
-        """   
+        """
         if not content:
             return False
@@ -3055,5 +3000,5 @@
         content = ''
         # go through the str params
-        for item in param: 
+        for item in param:
             # copy only the params shown
             if not item[2].IsShown():
@@ -3100,15 +3045,14 @@
             except:
                 pass
-            #if disfunc.count('array') == 0:
-            content +=  name + ',' + str(check) + ',' + value + disfunc + ':'
+            content += name + ',' + str(check) + ',' + value + disfunc + ':'
 
         return content
    
-    def get_clipboard(self):   
+    def get_clipboard(self):
         """
         Get strings in the clipboard
         """
-        text = ""  
-        # Get text from the clip board        
+        text = ""
+        # Get text from the clip board
         if wx.TheClipboard.Open():
             if wx.TheClipboard.IsSupported(wx.DataFormat(wx.DF_TEXT)):
@@ -3131,10 +3075,10 @@
         return flag
         
-    def get_paste_params(self, text=''): 
+    def get_paste_params(self, text=''):
         """
         Get the string copies of the param names and values in the tap
-        """  
-        context = {}    
-        # put the text into dictionary    
+        """
+        context = {}
+        # put the text into dictionary
         lines = text.split(':')
         if lines[0] != 'sansview_parameter_values':
@@ -3154,5 +3098,5 @@
                 context[name].append(poly_func)
                 try:
-                    # take the vals and weights for  array 
+                    # take the vals and weights for  array
                     array_values = item[4].split(' ')
                     array_weights = item[5].split(' ')
@@ -3168,21 +3112,21 @@
                 context[name].append(poly_func)
 
-        # Do it if params exist        
+        # Do it if params exist
         if  self.parameters != []:
-            # go through the parameters  
-            self._get_paste_helper(self.parameters, 
+            # go through the parameters
+            self._get_paste_helper(self.parameters,
                                    self.orientation_params, context)
 
             # go through the fittables
-            self._get_paste_helper(self.fittable_param, 
-                                   self.orientation_params_disp, 
+            self._get_paste_helper(self.fittable_param,
+                                   self.orientation_params_disp,
                                    context)
 
             # go through the fixed params
-            self._get_paste_helper(self.fixed_param, 
+            self._get_paste_helper(self.fixed_param,
                                    self.orientation_params_disp, context)
             
             # go through the str params
-            self._get_paste_helper(self.str_parameters, 
+            self._get_paste_helper(self.str_parameters,
                                    self.orientation_params, context)
                 
@@ -3196,8 +3140,8 @@
         : param param:  parameters
         : param orient_param: oritational params
-        : param content: dictionary [ name, value: name1.value1,...] 
+        : param content: dictionary [ name, value: name1.value1,...]
         """
         # go through the str params
-        for item in param: 
+        for item in param:
             # 2D
             if self.data.__class__.__name__ == "Data2D":
@@ -3218,5 +3162,5 @@
                         item[2].Enable(False)
                     if item[2].__class__.__name__ == "ComboBox":
-                        if self.model.fun_list.has_key(content[name][1]):
+                        if content[name][1] in self.model.fun_list:
                             fun_val = self.model.fun_list[content[name][1]]
                             self.model.setParam(name, fun_val)
@@ -3239,5 +3183,5 @@
                     if name in content.keys():
                         check = content[name][0]
-                        # Avoid changing combox content which needs special care
+                        # Avoid changing combox content
                         value = content[name][1:]
                         pd = value[0]
@@ -3254,10 +3198,8 @@
                             item[2].Enable(False)
                         if item[2].__class__.__name__ == "ComboBox":
-                            if self.model.fun_list.has_key(value[0]):
+                            if value[0] in self.model.fun_list:
                                 fun_val = self.model.fun_list[value[0]]
                                 self.model.setParam(name, fun_val)
                                 # save state
-                                #self._copy_parameters_state(self.str_parameters, 
-                                #    self.state.str_parameters)
                         self._paste_poly_help(item, value)
                         if check == 'True':
@@ -3294,14 +3236,14 @@
                         if len(pd_vals) == len(pd_weights):
                             self._set_disp_array_cb(item=item)
-                            self._set_array_disp_model(name=name, 
+                            self._set_array_disp_model(name=name,
                                                        disp=disp_model,
-                                                       values=pd_vals, 
+                                                       values=pd_vals,
                                                        weights=pd_weights)
                             is_array = True
                 except:
-                    pass 
+                    pass
                 if not is_array:
                     self._disp_obj_dict[name] = disp_model
-                    self.model.set_dispersion(name, 
+                    self.model.set_dispersion(name,
                                               disp_model)
                     self.state._disp_obj_dict[name] = \
@@ -3309,11 +3251,11 @@
                     self.model.set_dispersion(param_name, disp_model)
                     self.state.values = self.values
-                    self.state.weights = self.weights    
+                    self.state.weights = self.weights
                     self.model._persistency_dict[param_name] = \
-                                            [self.state.values, 
+                                            [self.state.values,
                                              self.state.weights]
                          
             except:
-                print "Error in BasePage._paste_poly_help: %s" % sys.exc_value 
+                print "Error in BasePage._paste_poly_help: %s" % sys.exc_value
     
     def _set_disp_array_cb(self, item):
@@ -3338,4 +3280,2 @@
         print "BasicPage.update_pinhole_smear was called: skipping"
         return
-
-        
