Index: theoryview/perspectives/theory/basepage.py
===================================================================
--- theoryview/perspectives/theory/basepage.py	(revision da9ac4e6fb87145553f38711a3fa2bde5b71b638)
+++ theoryview/perspectives/theory/basepage.py	(revision 2f60121365e0ece9b765fb57a132cf4e4b3a15a4)
@@ -1,4 +1,5 @@
 
-import sys, os
+import sys
+import os
 import wx
 import numpy
@@ -7,11 +8,14 @@
 import math
 import string
-from sans.guiframe.utils import format_number,check_float
+from sans.guiframe.utils import format_number
+from sans.guiframe.utils import check_float
 from sans.guicomm.events import StatusEvent
 import pagestate
 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
 _QMIN_DEFAULT = 0.001
@@ -19,5 +23,5 @@
 _NPTS_DEFAULT = 50
 #Control panel width 
-if sys.platform.count("darwin")==0:
+if sys.platform.count("darwin") == 0:
     PANEL_WIDTH = 450
     FONT_VARIANT = 0
@@ -38,10 +42,9 @@
     window_caption = "Basic page "
     
-    def __init__(self,parent, page_info= None, model_list_box=None):
+    def __init__(self,parent, page_info=None, model_list_box=None):
         wx.ScrolledWindow.__init__(self, parent,
-                 style= wx.FULL_REPAINT_ON_RESIZE )
+                 style=wx.FULL_REPAINT_ON_RESIZE)
         #Set window's font size 
         self.SetWindowVariant(variant=FONT_VARIANT)
-        
         ## parent of the page
         self.parent = parent
@@ -52,10 +55,9 @@
         ## owner of the page (fitting plugin)
         self.event_owner = None
-        
         if page_info is not None:
             ## 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
+            self.event_owner = page_info.event_owner
              ## current model
             self.model = page_info.model
@@ -71,56 +73,54 @@
         self._disp_obj_dict = {}
         ## selected parameters to apply dispersion
-        self.disp_cb_dict ={}
-
+        self.disp_cb_dict = {}
         ## smearer object
         self.smearer = None
-        
         ##list of model parameters. each item must have same length
         ## each item related to a given parameters
         ##[cb state, name, value, "+/-", error of fit, min, max , units]
-        self.parameters=[]
+        self.parameters = []
         # non-fittable parameter whose value is astring
         self.str_parameters = []
         ## list of parameters to fit , must be like self.parameters
-        self.param_toFit=[]
+        self.param_toFit = []
         ## list of looking like parameters but with non fittable parameters info
-        self.fixed_param=[]
+        self.fixed_param = []
         ## list of looking like parameters but with  fittable parameters info
-        self.fittable_param=[]
+        self.fittable_param = []
         ##list of dispersion parameters
-        self.disp_list=[]
-        self.disp_name=""
+        self.disp_list = []
+        self.disp_name = ""
         ## list of orientation parameters
-        self.orientation_params=[]
-        self.orientation_params_disp=[]
+        self.orientation_params = []
+        self.orientation_params_disp = []
         if self.model != None:
-            self.disp_list= self.model.getDispParamList()
+            self.disp_list = self.model.getDispParamList()
         self.multi_factor = None
         ##enable model 2D draw
-        self.enable2D= False
+        self.enable2D = False
         ## check that the fit range is correct to plot the model again
-        self.fitrange= True
-
+        self.fitrange = True
         ## Q range
-        self.qmin_x= _QMIN_DEFAULT
-        self.qmax_x= _QMAX_DEFAULT
-        self.num_points= _NPTS_DEFAULT
-        
+        self.qmin_x = _QMIN_DEFAULT
+        self.qmax_x = _QMAX_DEFAULT
+        self.num_points = _NPTS_DEFAULT
         ## Create memento to save the current state
-        self.state= PageState(parent= self.parent,model=self.model, data=self.data)
+        self.state = PageState(parent=self.parent,
+                               model=self.model, data=self.data)
         ## flag to determine if state has change
-        self.state_change= False
+        self.state_change = False
         ## save customized array
-        self.values=[]
-        self.weights=[]
+        self.values = []
+        self.weights = []
         ## retrieve saved state
-        self.number_saved_state= 0
+        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._undo = wx.MenuItem(self.popUpMenu,id, "Undo","cancel the previous action")
+        #self._undo = wx.MenuItem(self.popUpMenu,id, "Undo"
+        #,"cancel the previous action")
         #self.popUpMenu.AppendItem(self._undo)
         #self._undo.Enable(False)
@@ -128,5 +128,6 @@
         
         #id = wx.NewId()
-        #self._redo = wx.MenuItem(self.popUpMenu,id,"Redo"," Restore the previous action")
+        #self._redo = wx.MenuItem(self.popUpMenu,id,"Redo",
+        #" Restore the previous action")
         #self.popUpMenu.AppendItem(self._redo)
         #self._redo.Enable(False)
@@ -135,10 +136,10 @@
         #if sys.platform.count("win32")>0:        
         id = wx.NewId()
-        self._keep = wx.MenuItem(self.popUpMenu,id,"BookMark"," Keep the panel status to recall it later")
+        self._keep = wx.MenuItem(self.popUpMenu, id, "BookMark",
+                                 " Keep the panel status to recall it later")
         self.popUpMenu.AppendItem(self._keep)
         self._keep.Enable(True)
         wx.EVT_MENU(self, id, self.onSave)
         self.popUpMenu.AppendSeparator()
-    
         ## Default locations
         self._default_save_location = os.getcwd()     
@@ -167,15 +168,19 @@
         
         """
-        ## Set to True when the mouse is clicked while the whole string is selected
+        ## Set to True when the mouse is clicked 
+        #while the whole string is selected
         full_selection = False
         ## Call back for EVT_SET_FOCUS events
         _on_set_focus_callback = None
         
-        def __init__(self, parent, id=-1, value=wx.EmptyString, pos=wx.DefaultPosition, 
-                     size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.TextCtrlNameStr,
-                     kill_focus_callback = None, set_focus_callback  = None,
-                     mouse_up_callback   = None, text_enter_callback = None):
+        def __init__(self, parent, id=-1, value=wx.EmptyString,
+                      pos=wx.DefaultPosition, 
+                     size=wx.DefaultSize, style=0, 
+                     validator=wx.DefaultValidator, name=wx.TextCtrlNameStr,
+                     kill_focus_callback=None, set_focus_callback=None,
+                     mouse_up_callback=None, text_enter_callback=None):
              
-            wx.TextCtrl.__init__(self, parent, id, value, pos, size, style, validator, name)
+            wx.TextCtrl.__init__(self, parent, id, value, pos, size, style,
+                                 validator, name)
             
             # Bind appropriate events
@@ -198,11 +203,8 @@
             :param event: mouse event
             """
-            
             event.Skip()
             self.full_selection = True
             return self._on_set_focus_callback(event)
-        
- 
-            
+
         def _highlight_text(self, event):
             """
@@ -223,5 +225,5 @@
                     (start, end) = control.GetSelection()
                     if start==end:
-                        control.SetSelection(-1,-1)
+                        control.SetSelection(-1, -1)
                  
     def onContextMenu(self, event): 
@@ -239,5 +241,5 @@
         
         """
-        event = PreviousStateEvent(page = self)
+        event = PreviousStateEvent(page=self)
         wx.PostEvent(self.parent, event)
     
@@ -247,5 +249,5 @@
         
         """
-        event = NextStateEvent(page= self)
+        event = NextStateEvent(page=self)
         wx.PostEvent(self.parent, event)
     
@@ -263,5 +265,4 @@
         self.sizer5 = wx.BoxSizer(wx.VERTICAL)
         self.sizer6 = wx.BoxSizer(wx.VERTICAL)
-        
         self.sizer0.SetMinSize((PANEL_WIDTH,-1))
         self.sizer1.SetMinSize((PANEL_WIDTH,-1))
@@ -271,5 +272,4 @@
         self.sizer5.SetMinSize((PANEL_WIDTH,-1))
         #self.sizer6.SetMinSize((375,-1))
-        
         self.vbox.Add(self.sizer0)
         self.vbox.Add(self.sizer1)
@@ -280,5 +280,4 @@
         #self.vbox.Add(self.sizer6)
         
-        
     def set_layout(self):
         """
@@ -295,5 +294,5 @@
         """
         """
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         self.Layout()   
         self.SetAutoLayout(True)
@@ -333,22 +332,25 @@
         self.sizer4.Clear(True)
         name = "Polydispersity and Orientational Distribution"
-        box_description= wx.StaticBox(self, -1,name)
+        box_description= wx.StaticBox(self, -1, name)
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
         #----------------------------------------------------
-        self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), style=wx.RB_GROUP)
+        self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), 
+                                           style=wx.RB_GROUP)
         self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30))
        
-        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.disable_disp.GetId())
-        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, id=self.enable_disp.GetId())
+        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
+                  id=self.disable_disp.GetId())
+        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
+                  id=self.enable_disp.GetId())
         #MAC needs SetValue
         self.disable_disp.SetValue(True)
         sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_dispersion.Add((20,20))
+        sizer_dispersion.Add((20, 20))
         name=""#Polydispersity and \nOrientational Distribution "
-        sizer_dispersion.Add(wx.StaticText(self,-1,name))
+        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((10,10))
+        sizer_dispersion.Add((20, 20))
+        sizer_dispersion.Add(self.disable_disp)
+        sizer_dispersion.Add((10, 10))
         
         ## fill a sizer with the combobox to select dispersion type
@@ -364,26 +366,24 @@
             self.disp_box.Append(name,value)
         self.disp_box.SetStringSelection("gaussian") 
-        wx.EVT_COMBOBOX(self.disp_box,-1, self._on_select_Disp) 
+        wx.EVT_COMBOBOX(self.disp_box, -1, self._on_select_Disp) 
              
-        sizer_select_dispers.Add((10,10)) 
+        sizer_select_dispers.Add((10, 10)) 
         sizer_select_dispers.Add(self.model_disp) 
-        sizer_select_dispers.Add(self.disp_box,0,
-                wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5)
-      
+        sizer_select_dispers.Add(self.disp_box, 0,
+                wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, border=5)
         self.model_disp.Hide()
         self.disp_box.Hide()
-        
-        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(5,5)
-        boxsizer1.Add( self.sizer4_4  )
+        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(5, 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()
         self.Layout()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         self.Refresh()
         ## saving the state of enable dispersity button
@@ -391,5 +391,4 @@
         self.state.disable_disp= self.disable_disp.GetValue()
     
-    
     def select_disp_angle(self, event): 
         """
@@ -398,7 +397,7 @@
         :param event: radiobutton event
         """
-        self.values=[]
-        self.weights=[]
-        if event.GetEventObject()==self.noDisper_rbox:
+        self.values = []
+        self.weights = []
+        if event.GetEventObject() == self.noDisper_rbox:
             if self.noDisper_rbox.GetValue():
                 #No array dispersity apply yet
@@ -406,19 +405,19 @@
                 ## Redraw the model ???
                 self._draw_model()
-        # Go through the list of dispersion check boxes to identify which one has changed 
+        # Go through the list of dispersion check boxes to 
+        #identify which one has changed 
         for p in self.disp_cb_dict:
-            self.state.disp_cb_dict[p]=  self.disp_cb_dict[p].GetValue()
+            self.state.disp_cb_dict[p] = self.disp_cb_dict[p].GetValue()
             # Catch which one of the box was just checked or unchecked.
             if event.GetEventObject() == self.disp_cb_dict[p]:              
                 if self.disp_cb_dict[p].GetValue() == True:
-                    
-                    ##Temp. FIX for V1.0 regarding changing checkbox to radiobutton.
-                    ##This (self._reset_dispersity) should be removed when the array dispersion is fixed.                
+                    ##Temp. FIX for V1.0 regarding changing 
+                    #checkbox to radiobutton.
+                    ##This (self._reset_dispersity) should be removed 
+                    #when the array dispersion is fixed.                
                     self._reset_dispersity()
-
                     # The user wants this parameter to be averaged. 
                     # Pop up the file selection dialog.
                     path = self._selectDlg()
-                    
                     # If nothing was selected, just return
                     if path is None:
@@ -431,21 +430,20 @@
                         pass 
                     try:
-                        self.values,self.weights = self.read_file(path)
+                        self.values, self.weights = self.read_file(path)
                     except:
-                        msg="Could not read input file"
-                        wx.PostEvent(self.parent, StatusEvent(status= msg))
+                        msg = "Could not read input file"
+                        wx.PostEvent(self.parent, StatusEvent(status=msg))
                         return
-                    
-                    # If any of the two arrays is empty, notify the user that we won't
-                    # proceed 
+                    # If any of the two arrays is empty, notify the user 
+                    # that we won't proceed 
                     if self.values is None or self.weights is None or \
-                         self.values ==[] or self.weights ==[]:
-                        wx.PostEvent(self.parent, StatusEvent(status=\
-                            "The loaded %s distrubtion is corrupted or empty" % p))
+                         self.values == [] or self.weights == []:
+                        msg = "The loaded %s distrubtion is corrupted"
+                        msg += " or empty" % p
+                        wx.PostEvent(self.parent, StatusEvent(status=msg))
                         return
-                        
                     # Tell the user that we are about to apply the distribution
-                    wx.PostEvent(self.parent, StatusEvent(status=\
-                            "Applying loaded %s distribution: %s" % (p, path)))  
+                    msg = "Applying loaded %s distribution: %s" % (p, path)
+                    wx.PostEvent(self.parent, StatusEvent(status=msg))  
                     
                     # Create the dispersion objects
@@ -454,15 +452,18 @@
                     disp_model.set_weights(self.values, self.weights)
                    
-                    # Store the object to make it persist outside the scope of this method
+                    # Store the object to make it persist outside the scope 
+                    #of this method
                     #TODO: refactor model to clean this up?
                     self._disp_obj_dict[p] = disp_model
-                    self.state._disp_obj_dict [p]= disp_model
-                    self.state.values=[]
-                    self.state.weights=[]
+                    self.state._disp_obj_dict [p] = disp_model
+                    self.state.values = []
+                    self.state.weights = []
                     self.state.values = copy.deepcopy(self.values)
                     self.state.weights = copy.deepcopy(self.weights)
-                    # Set the new model as the dispersion object for the selected parameter
+                    # 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 so that
+                    # 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
@@ -470,6 +471,8 @@
 
                     self.model._persistency_dict = {}
-                    self.model._persistency_dict[p] = [self.values, self.weights]
-                    self.state.model._persistency_dict[p] = [self.values, self.weights]
+                    self.model._persistency_dict[p] = [self.values,
+                                                       self.weights]
+                    self.state.model._persistency_dict[p] = [self.values, 
+                                                             self.weights]
                 else:
                     self._reset_dispersity()
@@ -479,5 +482,5 @@
         
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
        
@@ -489,8 +492,8 @@
         ## post help message for the selected model 
         msg = self.popUpMenu.GetHelpString(event.GetId())
-        msg +=" reloaded"
-        wx.PostEvent(self.parent, StatusEvent(status = msg ))
-        
-        name= self.popUpMenu.GetLabel(event.GetId())
+        msg += " reloaded"
+        wx.PostEvent(self.parent, StatusEvent(status=msg))
+        
+        name = self.popUpMenu.GetLabel(event.GetId())
         self._on_select_model_helper()
         
@@ -500,5 +503,4 @@
             self.reset_page(previous_state)      
   
-                  
     def onSave(self, event):
         """
@@ -506,5 +508,5 @@
         
         """
-        if self.model==None:
+        if self.model == None:
             return 
         self.save_current_state()
@@ -524,19 +526,17 @@
         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)
+        year, month, day, hour, minute, second, _, _, _ = 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, StatusEvent(status = msg ))
+        msg += " Saved! right click on this page to retrieve this model"
+        wx.PostEvent(self.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)
         
@@ -556,14 +556,13 @@
         """
         try:
-            if path==None:
-                wx.PostEvent(self.parent, StatusEvent(status=\
-                            " Selected Distribution was not loaded: %s"%path))
+            if path == None:
+                msg = " Selected Distribution was not loaded: %s" % path
+                wx.PostEvent(self.parent, StatusEvent(status=msg))
                 return None, None
             input_f = open(path, 'r')
             buff = input_f.read()
             lines = buff.split('\n')
-            
             angles = []
-            weights=[]
+            weights = []
             for line in lines:
                 toks = line.split()
@@ -580,5 +579,4 @@
             raise 
     
-    
     def createMemento(self):
         """
@@ -587,5 +585,4 @@
         return self.state.clone()
     
-    
     def save_current_state(self):
         """
@@ -594,66 +591,53 @@
         """
         ## 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()
-
         self.state.enable2D = copy.deepcopy(self.enable2D)
-        self.state.values= copy.deepcopy(self.values)
+        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.data = copy.deepcopy(self.data)
         try:
             n = self.disp_box.GetCurrentSelection()
             dispersity= self.disp_box.GetClientData(n)
-            name= dispersity.__name__
+            name = dispersity.__name__
             self.disp_name = name
-            if name == "GaussianDispersion" :
+            if name == "GaussianDispersion":
                if hasattr(self,"cb1"):
-                   self.state.cb1= self.cb1.GetValue()
+                   self.state.cb1 = self.cb1.GetValue()
         except:
             pass
-        
-        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.smearer)
-        if hasattr(self,"enable_smearer"):
+        if hasattr(self, "enable_smearer"):
             self.state.enable_smearer = copy.deepcopy(self.enable_smearer.GetValue())
             self.state.disable_smearer = copy.deepcopy(self.disable_smearer.GetValue())
-            
-        if hasattr(self,"disp_box"):
+        if hasattr(self, "disp_box"):
             self.state.disp_box = self.disp_box.GetCurrentSelection()
-
-            if len(self.disp_cb_dict)>0:
-                for k , v in self.disp_cb_dict.iteritems():
-         
-                    if v ==None :
-                        self.state.disp_cb_dict[k]= v
+            if len(self.disp_cb_dict) > 0:
+                for k, v in self.disp_cb_dict.iteritems():
+                    if v == None :
+                        self.state.disp_cb_dict[k] = v
                     else:
                         try:
-                            self.state.disp_cb_dict[k]=v.GetValue()
+                            self.state.disp_cb_dict[k] = v.GetValue()
                         except:
-                            self.state.disp_cb_dict[k]= None
-           
-            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.disp_cb_dict[k] = None
+            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)
         ## save plotting range
         self._save_plotting_range()
-        
-        self.state.orientation_params =[]
-        self.state.orientation_params_disp =[]
-        self.state.parameters =[]
-        self.state.fittable_param =[]
-        self.state.fixed_param =[]
-
-        
+        self.state.orientation_params = []
+        self.state.orientation_params_disp = []
+        self.state.parameters = []
+        self.state.fittable_param = []
+        self.state.fixed_param = []
         ## save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.orientation_params,
@@ -661,7 +645,7 @@
         self._copy_parameters_state(self.orientation_params_disp,
                                      self.state.orientation_params_disp)
-        
         self._copy_parameters_state(self.parameters, self.state.parameters)
-        self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
+        self._copy_parameters_state(self.fittable_param, 
+                                    self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
   
@@ -675,30 +659,26 @@
             state of the graphic interface
         """
-        if state ==None:
+        if state == None:
             #self._undo.Enable(False)
             return 
-       
-        self.model= state.model
+        self.model = state.model
         self.data = state.data
-        if self.data !=None:
+        if self.data != None:
             from DataLoader.qsmearing import smear_selection
-            self.smearer= smear_selection( self.data )
-        self.enable2D= state.enable2D
+            self.smearer= smear_selection(self.data)
+        self.enable2D = state.enable2D
         self.engine_type = state.engine_type
-
         self.disp_cb_dict = state.disp_cb_dict
         self.disp_list = state.disp_list
-
         ## 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 )
+        self.struct_rbutton.SetValue(state.struct_rbutton)
         self.plugin_rbutton.SetValue(state.plugin_rbutton)
         ##draw sizer containing model parameters value for the current model
-        self._set_model_sizer_selection( self.model )
+        self._set_model_sizer_selection(self.model)
         self.set_model_param_sizer(self.model)
-
         ## reset value of combox box
-        self.structurebox.SetSelection(state.structurecombobox )
+        self.structurebox.SetSelection(state.structurecombobox)
         self.formfactorbox.SetSelection(state.formfactorcombobox)
         if state.multi_factor != None:
@@ -706,7 +686,6 @@
         #draw the pnael according to the new model parameter 
         self._on_select_model(event=None)
-       
         ## enable the view 2d button if this is a modelpage type
-        if hasattr(self,"model_view"):
+        if hasattr(self, "model_view"):
             if self.enable2D:
                 self.model_view.Disable()
@@ -716,7 +695,5 @@
         if hasattr(self, "cb1"):   
             self.cb1.SetValue(state.cb1)
-     
         ## reset state of checkbox,textcrtl  and  regular parameters value
-            
         self._reset_parameters_state(self.orientation_params_disp,
                                      state.orientation_params_disp)
@@ -725,67 +702,59 @@
         self._reset_parameters_state(self.str_parameters,
                                      state.str_parameters)
-        self._reset_parameters_state(self.parameters,state.parameters)    
+        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__     
-
+            n = self.disp_box.GetCurrentSelection()
+            dispersity = self.disp_box.GetClientData(n)
+            name = dispersity.__name__     
             self._set_dipers_Param(event=None)
-       
-            if name=="ArrayDispersion":
-                
+            if name == "ArrayDispersion":
                 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])
                         # Create the dispersion objects
                         from sans.models.dispersion_models import ArrayDispersion
                         disp_model = ArrayDispersion()
-                        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
-                                disp_model.set_weights(self.values, state.weights)
+                        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
+                                disp_model.set_weights(self.values, 
+                                                       state.weights)
                             else:
                                 self._reset_dispersity()
-                        
                         self._disp_obj_dict[item] = 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
                         self.model.set_dispersion(item, disp_model)
-                    
-                        self.model._persistency_dict[item] = [state.values, state.weights]
-                    
+                        self.model._persistency_dict[item] = [state.values, 
+                                                              state.weights]
             else:
                 keys = self.model.getParamList()
                 for item in keys:
-                    if item in self.disp_list and not self.model.details.has_key(item):
-                        self.model.details[item]=["",None,None]
-                for k,v in self.state.disp_cb_dict.iteritems():
+                    if item in self.disp_list and \
+                        not self.model.details.has_key(item):
+                        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.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
-
         ##plotting range restore    
         self._reset_plotting_range(state)
-
         ## smearing info  restore
-        if hasattr(self,"enable_smearer"):
-            ## set smearing value whether or not the data contain the smearing info
+        if hasattr(self, "enable_smearer"):
+            ## 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)           
-       
         ## 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()
-
         ## reset context menu items
         self._reset_context_menu()
@@ -799,7 +768,7 @@
         
         """
-        import os
+        #import os
         dlg = wx.FileDialog(self, "Choose a weight file",
-                                self._default_save_location , "", "*.*", wx.OPEN)
+                            self._default_save_location, "", "*.*", wx.OPEN)
         path = None
         if dlg.ShowModal() == wx.ID_OK:
@@ -817,8 +786,8 @@
             ## Add item in the context menu
             id = wx.NewId()
-            self.popUpMenu.Append(id,name, 'Save model and state %g'%self.number_saved_state)
+            hint_msg = 'Save model and state %g' % self.number_saved_state
+            self.popUpMenu.Append(id, name, hint_msg)
             wx.EVT_MENU(self, id, self.onResetModel)
-    
-    
+
     def _reset_plotting_range(self, state):
         """
@@ -828,7 +797,6 @@
         self.qmin.SetValue(str(state.qmin))
         self.qmax.SetValue(str(state.qmax)) 
-        if self.state.npts!=None:
+        if self.state.npts != None:
             self.npts.SetValue(str(state.npts)) 
-            
             
     def _save_typeOfmodel(self):
@@ -841,14 +809,12 @@
         self.state.struct_rbutton = self.struct_rbutton.GetValue()
         self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
-        self.state.structurebox= self.structurebox.GetCurrentSelection()
+        self.state.structurebox = self.structurebox.GetCurrentSelection()
         self.state.formfactorbox = self.formfactorbox.GetCurrentSelection()
-       
         #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 ):
+    def _save_plotting_range(self):
         """
         save the state of plotting range 
@@ -857,7 +823,6 @@
         self.state.qmin = self.qmin_x
         self.state.qmax = self.qmax_x 
-        if self.npts!=None:
-            self.state.npts= self.num_points
-            
+        if self.npts != None:
+            self.state.npts = self.num_points
             
     def _onparamEnter_helper(self):
@@ -871,9 +836,12 @@
         is_modified = False
         #self._undo.Enable(True)
-        if self.model !=None:
+        if self.model != None:
             try:
-                is_modified =self._check_value_enter( self.fittable_param ,is_modified)
-                is_modified =self._check_value_enter( self.fixed_param ,is_modified)
-                is_modified =self._check_value_enter( self.parameters ,is_modified) 
+                is_modified = self._check_value_enter(self.fittable_param,
+                                                     is_modified)
+                is_modified = self._check_value_enter(self.fixed_param,
+                                                     is_modified)
+                is_modified = self._check_value_enter(self.parameters,
+                                                      is_modified) 
             except:
                 pass
@@ -901,16 +869,13 @@
                         is_modified = True
                 else:
-                    msg= "Cannot Plot :Must enter a number!!!  "
-                    wx.PostEvent(self.parent, StatusEvent(status = msg ))
-                
-            
+                    msg = "Cannot Plot :Must enter a number!!!  "
+                    wx.PostEvent(self.parent, StatusEvent(status=msg))
             ## if any value is modify draw model with new value
             if is_modified:
-                self.state_change= True
+                self.state_change = True
                 self._draw_model() 
                 self.Refresh()
         return is_modified
                       
-               
     def _is_modified(self, is_modified):
         """
@@ -920,12 +885,12 @@
         return is_modified
                        
-    def _reset_parameters_state(self, listtorestore,statelist):
+    def _reset_parameters_state(self, listtorestore, statelist):
         """
         Reset the parameters at the given state
         
         """
-        if len(statelist)==0 or  len(listtorestore)==0 :
+        if len(statelist) == 0 or  len(listtorestore) == 0:
             return
-        if len(statelist)!=  len(listtorestore) :
+        if len(statelist) != len(listtorestore):
             return
 
@@ -934,11 +899,9 @@
             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[3]!=None:
+            if item_page[3] != None:
                 ## show or hide text +/-
                 if item_page_info[2]:
@@ -946,5 +909,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]:
@@ -953,5 +916,5 @@
                 else:
                     item_page[3].Hide()
-            if item_page[5]!=None:
+            if item_page[5] != None:
                 ## show of hide the text crtl for fitting error
                 if item_page_info[5][0]:
@@ -960,6 +923,5 @@
                 else:
                     item_page[5].Hide()
-                    
-            if item_page[6]!=None:
+            if item_page[6] != None:
                 ## show of hide the text crtl for fitting error
                 if item_page_info[6][0]:
@@ -977,43 +939,38 @@
         
         """
-        if len(listtocopy)==0:
+        if len(listtocopy) == 0:
             return
-       
         for item in listtocopy:
-  
             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()
-                
             min_value = None
             min_state = None
-            if item[5]!= None:
+            if item[5] != None:
                 min_value = item[5].GetValue()
                 min_state = item[5].IsShown()
-                
             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):
@@ -1022,11 +979,10 @@
         
         """
-        if model ==None:
+        if model == None:
             return
-        if hasattr(model ,"s_model"):
-            
-            class_name= model.s_model.__class__
-            name= model.s_model.name
-            flag= name != "NoStructure"
+        if hasattr(model, "s_model"):
+            class_name = model.s_model.__class__
+            name = model.s_model.name
+            flag = (name != "NoStructure")
             if flag and (class_name in self.model_list_box["Structure Factors"]):
                 self.structurebox.Show()
@@ -1036,24 +992,24 @@
                 items = self.structurebox.GetItems()
                 self.sizer1.Layout()
-                self.SetScrollbars(20,20,25,65)
+                self.SetScrollbars(20, 20, 25, 65)
                 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
             self.formfactorbox.Clear()
-            
             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
@@ -1067,5 +1023,4 @@
                 else:
                     self.plugin_rbutton.SetValue(True)
-               
                 if class_name in list:
                     ## fill the form factor list with new model
@@ -1074,5 +1029,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
@@ -1087,5 +1042,6 @@
     
             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"]:
                     if class_name in self.model_list_box["P(Q)*S(Q)"]:
                         self.structurebox.Show()
@@ -1103,9 +1059,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
@@ -1128,5 +1085,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
@@ -1142,6 +1099,6 @@
          
         """
-        if self.model !=None:
-            temp_smear=None
+        if self.model != None:
+            temp_smear = None
             if hasattr(self, "enable_smearer"):
                 if self.enable_smearer.GetValue():
@@ -1164,5 +1121,5 @@
         ##For MAC, this should defined here.
         if box_sizer == None:
-            box_description= wx.StaticBox(self, -1,str(title))
+            box_description = wx.StaticBox(self, -1, str(title))
             boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
         else:
@@ -1170,59 +1127,54 @@
         sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)        
         #--------------------------------------------------------
-        self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', style=wx.RB_GROUP)
-        self.shape_indep_rbutton = wx.RadioButton(self, -1, "Shape-Independent")
+        self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', 
+                                            style=wx.RB_GROUP)
+        self.shape_indep_rbutton = wx.RadioButton(self, -1, 
+                                                  "Shape-Independent")
         self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ")
         self.plugin_rbutton = wx.RadioButton(self, -1, "Customized Models")
-                
-        self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,
-                            id= self.shape_rbutton.GetId() ) 
-        self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,
-                            id= self.shape_indep_rbutton.GetId() ) 
-        self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,
-                            id= self.struct_rbutton.GetId() ) 
-        self.Bind( wx.EVT_RADIOBUTTON, self._show_combox,
-                            id= self.plugin_rbutton.GetId() )  
+        self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+                            id=self.shape_rbutton.GetId()) 
+        self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+                            id=self.shape_indep_rbutton.GetId()) 
+        self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+                            id=self.struct_rbutton.GetId()) 
+        self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+                            id=self.plugin_rbutton.GetId())  
         #MAC needs SetValue
         self.shape_rbutton.SetValue(True)
-      
-        sizer_radiobutton = wx.GridSizer(2, 2,5, 5)
+        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5)
         sizer_radiobutton.Add(self.shape_rbutton)
         sizer_radiobutton.Add(self.shape_indep_rbutton)
         sizer_radiobutton.Add(self.plugin_rbutton)
         sizer_radiobutton.Add(self.struct_rbutton)
-        
         sizer_buttons.Add(sizer_radiobutton)
         # detail button
-        if object !=None:
-            sizer_buttons.Add((50,0))
+        if object != None:
+            sizer_buttons.Add((50, 0))
             sizer_buttons.Add(object)
-            
         sizer_selection = wx.BoxSizer(wx.HORIZONTAL)
         mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL)
-        self.text1 = wx.StaticText( self,-1,"" )
-        self.text2 = wx.StaticText( self,-1,"P(Q)*S(Q)" )
-        self.mutifactor_text = wx.StaticText( self,-1,"No. of Shells: " )
-        self.mutifactor_text1 = wx.StaticText( self,-1,"" )
-        self.show_sld_button = wx.Button( self,-1,"Show SLD Profile" )
+        self.text1 = wx.StaticText(self, -1, "")
+        self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)")
+        self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ")
+        self.mutifactor_text1 = wx.StaticText(self, -1, "")
+        self.show_sld_button = wx.Button(self, -1, "Show SLD Profile")
         self.show_sld_button.Bind(wx.EVT_BUTTON,self._on_show_sld)
-        self.formfactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY)
-        if self.model!=None:
+        self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
+        if self.model!= None:
             self.formfactorbox.SetValue(self.model.name)
-            
-            
-        self.structurebox = wx.ComboBox(self, -1,style=wx.CB_READONLY)
-        self.multifactorbox = wx.ComboBox(self, -1,style=wx.CB_READONLY)
-        wx.EVT_COMBOBOX(self.formfactorbox,-1, self._on_select_model)
-        wx.EVT_COMBOBOX(self.structurebox,-1, self._on_select_model)
-        wx.EVT_COMBOBOX(self.multifactorbox,-1, self._on_select_model)
-    
+        self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
+        self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
+        wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model)
+        wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model)
+        wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model)
         ## fill combox box
-        if len(self.model_list_box)>0:
-            self._populate_box( self.formfactorbox,self.model_list_box["Shapes"])
-       
-        if len(self.model_list_box)>0:
-            self._populate_box( self.structurebox,
+        if len(self.model_list_box) > 0:
+            self._populate_box(self.formfactorbox, 
+                               self.model_list_box["Shapes"])
+        if len(self.model_list_box) > 0:
+            self._populate_box(self.structurebox,
                                 self.model_list_box["Structure Factors"])
-            self.structurebox.Insert("None", 0,None)
+            self.structurebox.Insert("None", 0, None)
             self.structurebox.SetSelection(0)
             self.structurebox.Hide()
@@ -1230,5 +1182,4 @@
             self.structurebox.Disable()
             self.text2.Disable()
-             
             if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]:
                 self.structurebox.Show()
@@ -1236,39 +1187,34 @@
                 self.structurebox.Enable()
                 self.text2.Enable()            
-        
         ## check model type to show sizer
-        if self.model !=None:
-            self._set_model_sizer_selection( self.model )
-        
+        if self.model != None:
+            self._set_model_sizer_selection(self.model)
         sizer_selection.Add(self.text1)
-        sizer_selection.Add((5,5))
+        sizer_selection.Add((5, 5))
         sizer_selection.Add(self.formfactorbox)
-        sizer_selection.Add((5,5))
+        sizer_selection.Add((5, 5))
         sizer_selection.Add(self.text2)
-        sizer_selection.Add((5,5))
+        sizer_selection.Add((5, 5))
         sizer_selection.Add(self.structurebox)
-        #sizer_selection.Add((5,5))
-        mutifactor_selection.Add((10,5))
+        #sizer_selection.Add((5, 5))
+        mutifactor_selection.Add((10, 5))
         mutifactor_selection.Add(self.mutifactor_text)
         mutifactor_selection.Add(self.multifactorbox)
-        mutifactor_selection.Add((5,5))
+        mutifactor_selection.Add((5, 5))
         mutifactor_selection.Add(self.mutifactor_text1)
-        mutifactor_selection.Add((10,5))
+        mutifactor_selection.Add((10, 5))
         mutifactor_selection.Add(self.show_sld_button)
-        
-        boxsizer1.Add( sizer_buttons )
-        boxsizer1.Add( (15,15))
-        boxsizer1.Add( sizer_selection )
-        boxsizer1.Add( (10,10))
+        boxsizer1.Add(sizer_buttons)
+        boxsizer1.Add((15, 15))
+        boxsizer1.Add(sizer_selection)
+        boxsizer1.Add((10,10))
         boxsizer1.Add(mutifactor_selection)
-        
         self._set_multfactor_combobox()
         self.multifactorbox.SetSelection(1)
         self.show_sld_button.Hide()
-        
         #--------------------------------------------------------
-        sizer.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
+        sizer.Add(boxsizer1, 0, wx.EXPAND|wx.ALL, 10)
         sizer.Layout()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         
     def _on_show_sld(self, event=None):
@@ -1277,14 +1223,13 @@
     	"""
         # get profile data
-        x,y=self.model.getProfile()
-
+        x, y = self.model.getProfile()
         from danse.common.plottools import Data1D
         #from profile_dialog import SLDPanel
         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 = SLDPanel(self, data=sld_data, axes=self.sld_axes, id=-1)
         self.panel.ShowModal()
 
@@ -1295,6 +1240,6 @@
         """
         # build content of the combobox
-        for idx in range(0,multiplicity):
-            self.multifactorbox.Append(str(idx),int(idx))
+        for idx in range(0, multiplicity):
+            self.multifactorbox.Append(str(idx), int(idx))
             #self.multifactorbox.SetSelection(1) 
         self._hide_multfactor_combobox()
@@ -1320,5 +1265,4 @@
             self.multifactorbox.Hide()   
      
-        
     def _show_combox(self, event):
         """
@@ -1327,39 +1271,35 @@
         """
         ## Don't want to populate combo box again if the event comes from check box
-        if self.shape_rbutton.GetValue()and\
-             event.GetEventObject()==self.shape_rbutton:
+        if self.shape_rbutton.GetValue() and \
+             event.GetEventObject() == self.shape_rbutton:
             ##fill the combobox with form factor list
             self.structurebox.SetSelection(0)
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,self.model_list_box["Shapes"])
-            
-        if self.shape_indep_rbutton.GetValue()and\
-             event.GetEventObject()==self.shape_indep_rbutton:
+            self._populate_box(self.formfactorbox,
+                               self.model_list_box["Shapes"])
+        if self.shape_indep_rbutton.GetValue() and \
+             event.GetEventObject() == self.shape_indep_rbutton:
             ##fill the combobox with shape independent  factor list
             self.structurebox.SetSelection(0)
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
+            self._populate_box(self.formfactorbox,
                                 self.model_list_box["Shape-Independent"])
-            
-        if self.struct_rbutton.GetValue() and\
-             event.GetEventObject()==self.struct_rbutton:
+        if self.struct_rbutton.GetValue() and \
+             event.GetEventObject() == self.struct_rbutton:
             ##fill the combobox with structure factor list
             self.structurebox.SetSelection(0)
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
+            self._populate_box(self.formfactorbox,
                                 self.model_list_box["Structure Factors"])
-           
-        if self.plugin_rbutton.GetValue()and\
-             event.GetEventObject()==self.plugin_rbutton:
-           
+        if self.plugin_rbutton.GetValue() and \
+             event.GetEventObject() == self.plugin_rbutton:
             ##fill the combobox with form factor list
             self.structurebox.Disable()
             self.formfactorbox.Clear()
-            self._populate_box( self.formfactorbox,
+            self._populate_box(self.formfactorbox,
                                 self.model_list_box["Customized Models"])
-        
         self._on_select_model(event=None)
         self._save_typeOfmodel()
@@ -1368,5 +1308,5 @@
         self.Layout()
         self.Refresh()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
             
     def _populate_box(self, combobox, list):
@@ -1378,11 +1318,10 @@
         """
         for models in list:
-            model= models()
+            model = models()
             name = model.__class__.__name__
             if models.__name__!="NoStructure":
                 if hasattr(model, "name"):
                     name = model.name
-                combobox.Append(name,models)
-     
+                combobox.Append(name, models)
         return 0
     
@@ -1392,24 +1331,20 @@
         
         """
-        tcrtl= event.GetEventObject()
-        
+        tcrtl = event.GetEventObject()
         #Clear msg if previously shown.
-        msg= ""
-        wx.PostEvent(self.parent, StatusEvent(status = msg ))
-        
+        msg = ""
+        wx.PostEvent(self.parent, StatusEvent(status=msg))
         ## save current state
         self.save_current_state()
-        if event !=None:
+        if event != None:
             #self._undo.Enable(True)
-            event = PageInfoEvent(page = self)
+            event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, event)
-              
         if check_float(tcrtl):
-            
             self._onparamEnter_helper()
             #event.Skip()
         else:
-            msg= "Cannot Plot :Must enter a number!!!  "
-            wx.PostEvent(self.parent, StatusEvent(status = msg ))
+            msg = "Cannot Plot :Must enter a number!!!  "
+            wx.PostEvent(self.parent, StatusEvent(status=msg))
             #event.Skip()
             return 
@@ -1420,18 +1355,16 @@
         
         """
-        
-        tcrtl= event.GetEventObject()
+        tcrtl = event.GetEventObject()
         #Clear msg if previously shown.
-        msg= ""
-        wx.PostEvent(self.parent, StatusEvent(status = msg ))
+        msg = ""
+        wx.PostEvent(self.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())
                 tcrtl.SetBackgroundColour(wx.WHITE)
-
                 # If qmin and qmax have been modified, update qmin and qmax
-                if self._validate_qrange( self.qmin, self.qmax):
+                if self._validate_qrange(self.qmin, self.qmax):
                     tempmin = float(self.qmin.GetValue())
                     if tempmin != self.qmin_x:
@@ -1442,12 +1375,11 @@
                 else:
                     tcrtl.SetBackgroundColour("pink")
-                    msg= "Model Error:wrong value entered : %s"% sys.exc_value
-                    wx.PostEvent(self.parent, StatusEvent(status = msg ))
+                    msg = "Model Error:wrong value entered : %s" % sys.exc_value
+                    wx.PostEvent(self.parent, StatusEvent(status=msg))
                     return 
-                
             except:
                 tcrtl.SetBackgroundColour("pink")
-                msg= "Model Error:wrong value entered : %s"% sys.exc_value
-                wx.PostEvent(self.parent, StatusEvent(status = msg ))
+                msg = "Model Error:wrong value entered : %s" % sys.exc_value
+                wx.PostEvent(self.parent, StatusEvent(status=msg))
                 return 
             #Check if # of points for theory model are valid(>0).
@@ -1459,17 +1391,15 @@
                         is_modified = True
                 else:
-                    msg= "Cannot Plot :No npts in that Qrange!!!  "
-                    wx.PostEvent(self.parent, StatusEvent(status = msg ))
-           
+                    msg = "Cannot Plot :No npts in that Qrange!!!  "
+                    wx.PostEvent(self.parent, StatusEvent(status=msg))
         else:
            tcrtl.SetBackgroundColour("pink")
-           msg= "Model Error:wrong value entered!!!"
-           wx.PostEvent(self.parent, StatusEvent(status = msg ))
-           
+           msg = "Model Error:wrong value entered!!!"
+           wx.PostEvent(self.parent, StatusEvent(status=msg))
         #self._undo.Enable(True)
         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._draw_model()
@@ -1482,12 +1412,10 @@
         ## reset dictionary containing reference to dispersion
         self._disp_obj_dict = {}
-        self.disp_cb_dict ={}
-        
+        self.disp_cb_dict = {}
         f_id = self.formfactorbox.GetCurrentSelection()
         #For MAC
         form_factor = None
         if f_id >= 0:
-            form_factor = self.formfactorbox.GetClientData( f_id )
-
+            form_factor = self.formfactorbox.GetClientData(f_id)
         if not form_factor in  self.model_list_box["multiplication"]:
             self.structurebox.Hide()
@@ -1501,5 +1429,4 @@
             self.structurebox.Enable()
             self.text2.Enable()
-
         if form_factor != None:    
             # set multifactor for Mutifunctional models    
@@ -1517,9 +1444,10 @@
 
                 # Check max value
-                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 =1
+                if self.multi_factor == None:
+                    self.multi_factor =1
                 form_factor = form_factor(int(self.multi_factor))
                 self.multifactorbox.SetSelection(m_id)
@@ -1544,25 +1472,21 @@
             self.show_sld_button.Hide()
             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())
         else:
             if form_factor != None:
-                self.model= form_factor
+                self.model = form_factor
             else:
                 self.model = None
                 return self.model
-        
         ## 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.Layout()     
@@ -1598,5 +1522,5 @@
                 qmax_ctrl.Refresh()
                 msg= "Invalid Q range: Q min must be smaller than Q max"
-                wx.PostEvent(self.parent, StatusEvent(status = msg))
+                wx.PostEvent(self.parent, StatusEvent(status=msg))
                 return False
         return True
@@ -1611,5 +1535,5 @@
         """  
         is_modified =  modified
-        if len(list)==0:
+        if len(list) == 0:
             return is_modified
         for item in list:
@@ -1620,7 +1544,6 @@
             #try:
             name = str(item[1])
-
             try:     
-                value= float(item[2].GetValue())
+                value = float(item[2].GetValue())
                 # If the value of the parameter has changed,
                 # +update the model and set the is_modified flag
@@ -1630,6 +1553,5 @@
             except:
                 msg = "Wrong parameter value entered "
-                wx.PostEvent(self.parent, StatusEvent(status = msg))
-                
+                wx.PostEvent(self.parent, StatusEvent(status=msg))
         return is_modified 
     
@@ -1638,26 +1560,22 @@
         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 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)
         
         """
-        
         self._reset_dispersity()
-    
-        if self.model ==None:
+        if self.model == None:
             self.model_disp.Hide()
             self.disp_box.Hide()
             self.sizer4_4.Clear(True)
             return
-
         if self.enable_disp.GetValue():
             self.model_disp.Show(True)
             self.disp_box.Show(True)
             ## layout for model containing no dispersity parameters
-            
-            self.disp_list= self.model.getDispParamList()
-             
-            if len(self.disp_list)==0 and len(self.disp_cb_dict)==0:
+            self.disp_list = self.model.getDispParamList()
+            if len(self.disp_list) == 0 and len(self.disp_cb_dict) == 0:
                 self._layout_sizer_noDipers()  
             else:
@@ -1669,10 +1587,9 @@
             self.disp_box.SetSelection(0) 
             self.sizer4_4.Clear(True)
-            
         ## post state to fit panel 
         self.save_current_state()
-        if event !=None:
+        if event != None:
             #self._undo.Enable(True)
-            event = PageInfoEvent(page = self)
+            event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, event)
         #draw the model with the current dispersity
@@ -1683,5 +1600,4 @@
         self.Refresh()      
           
-        
     def _layout_sizer_noDipers(self):
         """
@@ -1689,20 +1605,19 @@
         
         """
-        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.model_disp.Hide()
         self.disp_box.Hide()
         self.sizer4_4.Clear(True)
         model_disp = wx.StaticText(self, -1, 'No PolyDispersity for this model')
-        self.sizer4_4.Add(model_disp,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        self.sizer4_4.Add(model_disp,(iy, ix), (1,1), 
+                          wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         self.sizer4_4.Layout()
         self.sizer4.Layout()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
       
-            
     def _reset_dispersity(self):
         """
@@ -1710,39 +1625,35 @@
          
         """
-        if len(self.param_toFit)>0:
+        if len(self.param_toFit) > 0:
             for item in self.fittable_param:
                 if item in self.param_toFit:
                     self.param_toFit.remove(item)
-
             for item in self.orientation_params_disp:
                 if item in self.param_toFit:
                     self.param_toFit.remove(item)
-         
-        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:
+        self.fittable_param = []
+        self.fixed_param = []
+        self.orientation_params_disp = []
+        self.values = []
+        self.weights = []
+        from sans.models.dispersion_models import GaussianDispersion
+        from sans.models.dispersion_models import ArrayDispersion
+        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) :
+        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)
                 except:
-
                     pass
-
         ## save state into
         self.save_current_state()
@@ -1750,6 +1661,5 @@
         self.Refresh()
                   
-            
-    def _on_select_Disp(self,event):
+    def _on_select_Disp(self, event):
         """
         allow selecting different dispersion
@@ -1759,30 +1669,25 @@
         n = self.disp_box.GetCurrentSelection()
         name = self.disp_box.GetValue()
-        dispersity= self.disp_box.GetClientData(n)
+        dispersity = self.disp_box.GetClientData(n)
         self.disp_name = name
-        
         if name.lower() == "array":
             self._set_sizer_arraydispersion()
         else:
-            self._set_sizer_dispersion(dispersity= dispersity)
-            
-        self.state.disp_box= n
+            self._set_sizer_dispersion(dispersity=dispersity)
+        self.state.disp_box = n
         ## Redraw the model
         self._draw_model() 
         #self._undo.Enable(True)
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
-        
         self.sizer4_4.Layout()
         self.sizer4.Layout()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         
     def _set_sizer_arraydispersion(self):
         """
         draw sizer with array dispersity  parameters
-        
-        """
-        
-        if len(self.param_toFit)>0:
+        """
+        if len(self.param_toFit) > 0:
             for item in self.fittable_param:
                 if item in self.param_toFit:
@@ -1794,71 +1699,71 @@
             if item in self.model.fixed:
                 del self.model.details [item]                           
-
-        self.fittable_param=[]
-        self.fixed_param=[]
-        self.orientation_params_disp=[]
+        self.fittable_param = []
+        self.fixed_param = []
+        self.orientation_params_disp = []
         self.sizer4_4.Clear(True) 
         self._reset_dispersity()
-        ix=0
-        iy=1     
+        ix = 0
+        iy = 1     
         disp1 = wx.StaticText(self, -1, 'Array Dispersion')
-        self.sizer4_4.Add(disp1,( iy, ix),(1,1),  wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        
-        # Look for model parameters to which we can apply an ArrayDispersion model
+        self.sizer4_4.Add(disp1, (iy, ix), (1, 1),  
+                          wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        # Look for model parameters to which we can apply 
+        # an ArrayDispersion model
         # Add a check box for each parameter.
         self.disp_cb_dict = {}
         ix+=1 
-        self.noDisper_rbox = wx.RadioButton(self, -1,"None", (10, 10),style= wx.RB_GROUP)
-        self.Bind(wx.EVT_RADIOBUTTON,self.select_disp_angle , id=self.noDisper_rbox.GetId())
+        self.noDisper_rbox = wx.RadioButton(self, -1, "None", 
+                                            (10, 10), style=wx.RB_GROUP)
+        self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, 
+                  id=self.noDisper_rbox.GetId())
         #MAC needs SetValue
         self.noDisper_rbox.SetValue(True)
         self.sizer4_4.Add(self.noDisper_rbox, (iy, ix),
-                           (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        
+                           (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         for p in self.model.dispersion.keys():
             if not p in self.model.orientation_params:
-                ix+=1 
+                ix += 1 
                 self.disp_cb_dict[p] = wx.RadioButton(self, -1, p, (10, 10))
-                self.state.disp_cb_dict[p]=  self.disp_cb_dict[p].GetValue()
-                self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, id=self.disp_cb_dict[p].GetId())
-                self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        
+                self.state.disp_cb_dict[p] = self.disp_cb_dict[p].GetValue()
+                self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, 
+                          id=self.disp_cb_dict[p].GetId())
+                self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), 
+                                  wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         for p in self.model.dispersion.keys():
             if p in self.model.orientation_params:
-                ix+=1 
+                ix += 1 
                 self.disp_cb_dict[p] = wx.RadioButton(self, -1, p, (10, 10))
-                self.state.disp_cb_dict[p]=  self.disp_cb_dict[p].GetValue()
-                if not (self.enable2D or self.data.__class__.__name__ =="Data2D"):
+                self.state.disp_cb_dict[p] = self.disp_cb_dict[p].GetValue()
+                if not (self.enable2D or \
+                        self.data.__class__.__name__ == "Data2D"):
                     self.disp_cb_dict[p].Hide()
                 else:
                     self.disp_cb_dict[p].Show(True)
-                self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, id=self.disp_cb_dict[p].GetId())
-                self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-
-
-        ix =0
-        iy +=1 
-        self.sizer4_4.Add((20,20),(iy,ix),(1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)        
+                self.Bind(wx.EVT_RADIOBUTTON, self.select_disp_angle, 
+                          id=self.disp_cb_dict[p].GetId())
+                self.sizer4_4.Add(self.disp_cb_dict[p], (iy, ix), (1,1),
+                                   wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        ix = 0
+        iy += 1 
+        self.sizer4_4.Add((20, 20), (iy, ix), (1, 1), 
+                          wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)        
         self.Layout()
-
-        self.state.orientation_params =[]
-        self.state.orientation_params_disp =[]
-        self.state.parameters =[]
-        self.state.fittable_param =[]
-        self.state.fixed_param =[]
-        
+        self.state.orientation_params = []
+        self.state.orientation_params_disp = []
+        self.state.parameters = []
+        self.state.fittable_param = []
+        self.state.fixed_param = []
         ## save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.orientation_params,
                                      self.state.orientation_params)
-
         self._copy_parameters_state(self.orientation_params_disp,
                                      self.state.orientation_params_disp)
-        
         self._copy_parameters_state(self.parameters, self.state.parameters)
-        self._copy_parameters_state(self.fittable_param, self.state.fittable_param)
+        self._copy_parameters_state(self.fittable_param, 
+                                    self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
-    
         ## post state to fit panel
-        event = PageInfoEvent(page = self)
+        event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
         
@@ -1871,5 +1776,5 @@
         #--------------------------------------------------------------
         if box_sizer == None:
-            box_description= wx.StaticBox(self, -1,str(title))
+            box_description= wx.StaticBox(self, -1, str(title))
             boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
         else:
@@ -1877,44 +1782,40 @@
             boxsizer1 = box_sizer
 
-        self.qmin    = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER,
-                                            kill_focus_callback = self._onQrangeEnter,
-                                            text_enter_callback = self._onQrangeEnter)
+        self.qmin = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH, 20),
+                                       style=wx. TE_PROCESS_ENTER,
+                                    kill_focus_callback=self._onQrangeEnter,
+                                    text_enter_callback=self._onQrangeEnter)
         self.qmin.SetValue(str(self.qmin_x))
         self.qmin.SetToolTipString("Minimun value of Q in linear scale.")
      
-        self.qmax    = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20),style=wx.TE_PROCESS_ENTER,
-                                            kill_focus_callback = self._onQrangeEnter,
-                                            text_enter_callback = self._onQrangeEnter)
+        self.qmax = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),
+                                       style=wx.TE_PROCESS_ENTER,
+                                    kill_focus_callback=self._onQrangeEnter,
+                                    text_enter_callback=self._onQrangeEnter)
         self.qmax.SetValue(str(self.qmax_x))
         self.qmax.SetToolTipString("Maximum value of Q in linear scale.")
-        
         id = wx.NewId()
-        self.reset_qrange =wx.Button(self,id,'Reset',size=(70,23))
-      
-        self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked,id=id)
+        self.reset_qrange = wx.Button(self, id, 'Reset', size=(70, 23))
+        self.reset_qrange.Bind(wx.EVT_BUTTON, self.on_reset_clicked, id=id)
         self.reset_qrange.SetToolTipString("Reset Q range to the default values")
-     
-        sizer_horizontal=wx.BoxSizer(wx.HORIZONTAL)
-        sizer= wx.GridSizer(3, 3,2, 5)
-        
+        sizer_horizontal = wx.BoxSizer(wx.HORIZONTAL)
+        sizer = wx.GridSizer(3, 3, 2, 5)
         sizer.Add(wx.StaticText(self, -1, '    Q range'))     
         sizer.Add(wx.StaticText(self, -1, ' Min'))
         sizer.Add(wx.StaticText(self, -1, ' Max'))
         sizer.Add(self.reset_qrange)   
-             
         sizer.Add(self.qmin)
         sizer.Add(self.qmax)
         sizer_horizontal.Add(sizer)
-        if object!=None:
+        if object != None:
             sizer_horizontal.Add(object)
-        
-        if object1!=None:
+        if object1 != None:
            boxsizer1.Add(object1) 
-           boxsizer1.Add((10,10))
+           boxsizer1.Add((10, 10))
         boxsizer1.Add(sizer_horizontal)
         ## save state
         self.save_current_state()
         #----------------------------------------------------------------
-        self.sizer5.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
+        self.sizer5.Add(boxsizer1, 0, wx.EXPAND|wx.ALL, 10)
         self.sizer5.Layout()
 
@@ -1926,7 +1827,6 @@
         # Skipping save state functionality for release 0.9.0
         return
-    
         self.sizer6.Clear(True)
-        box_description= wx.StaticBox(self, -1,"Save Model")
+        box_description= wx.StaticBox(self, -1, "Save Model")
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
         sizer_save = wx.BoxSizer(wx.HORIZONTAL)
@@ -1934,16 +1834,13 @@
         self.btSave_title = wx.StaticText(self, -1, 'Save the current Model')
         self.btSave = wx.Button(self,wx.NewId(),'Save')
-        self.btSave.Bind(wx.EVT_BUTTON, self.onSave,id= self.btSave.GetId())
+        self.btSave.Bind(wx.EVT_BUTTON, self.onSave,id=self.btSave.GetId())
         self.btSave.SetToolTipString("Save the current Model")
-        
         sizer_save.Add(self.btSave_title)  
-        sizer_save.Add((20,20),0, wx.LEFT|wx.RIGHT|wx.EXPAND,45)  
-             
+        sizer_save.Add((20, 20), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 45)  
         sizer_save.Add(self.btSave)     
-        
         boxsizer1.Add(sizer_save)
-        self.sizer6.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10)
+        self.sizer6.Add(boxsizer1, 0, wx.EXPAND|wx.ALL, 10)
         self.sizer6.Layout()
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         
     def _lay_out(self):
@@ -1971,5 +1868,5 @@
             time.sleep(1)
              
-    def on_reset_clicked(self,event):
+    def on_reset_clicked(self, event):
         """
         On 'Reset' button  for Q range clicked
@@ -1978,9 +1875,9 @@
         ##For 3 different cases: Data2D, Data1D, and theory
         if 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)
+            self.qmax_x = math.sqrt(x * x + y * y)
         elif self.data.__class__.__name__ == "Data1D":
             self.qmin_x = min(self.data.x)
@@ -1991,8 +1888,6 @@
             self.num_points = _NPTS_DEFAULT            
             self.state.npts = self.num_points
-            
         self.state.qmin = self.qmin_x
         self.state.qmax = self.qmax_x
-        
         #reset the q range values
         self._reset_plotting_range(self.state)
Index: theoryview/perspectives/theory/help_panel.py
===================================================================
--- theoryview/perspectives/theory/help_panel.py	(revision 74755ffa1ce766f8db2e7443abc981f716782e5c)
+++ theoryview/perspectives/theory/help_panel.py	(revision 2f60121365e0ece9b765fb57a132cf4e4b3a15a4)
@@ -7,5 +7,5 @@
 
 class HelpWindow(wx.Frame):
-    def __init__(self, parent, id, title= 'HelpWindow', pageToOpen=None):
+    def __init__(self, parent, id, title='HelpWindow', pageToOpen=None):
         wx.Frame.__init__(self, parent, id, title, size=(850, 500))
         """
@@ -16,5 +16,5 @@
         splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
         rpanel = wx.Panel(splitter, -1)
-        lpanel = wx.Panel(splitter, -1,style=wx.BORDER_SUNKEN)
+        lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)
         
         vbox = wx.BoxSizer(wx.VERTICAL)
@@ -27,5 +27,5 @@
         font.SetPointSize(10)
         st.SetFont(font)
-        hbox.Add(st, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
+        hbox.Add(st, 1, wx.TOP|wx.BOTTOM|wx.LEFT, 5)
         header.SetSizer(hbox)
         vbox.Add(header, 0, wx.EXPAND)
@@ -41,15 +41,16 @@
         fontl.SetPointSize(10)
         lst.SetFont(fontl)
-        hboxl.Add(lst, 1, wx.TOP | wx.BOTTOM | wx.LEFT, 5)
+        hboxl.Add(lst, 1, wx.TOP|wx.BOTTOM|wx.LEFT, 5)
         headerl.SetSizer(hboxl)
         vboxl.Add(headerl, 0, wx.EXPAND)
         self.lhelp = html.HtmlWindow(lpanel, -1, style=wx.NO_BORDER)
-        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER, size=(500,-1))
-        page1="""<html>
+        self.rhelp = html.HtmlWindow(rpanel, -1, 
+                                     style=wx.NO_BORDER, size=(500, -1))
+        page1 = """<html>
             <body>
              <p>Select topic on Menu</p>
             </body>
             </html>"""
-        page="""<html>
+        page = """<html>
             <body>
             <ul>
@@ -60,22 +61,18 @@
         self.rhelp.SetPage(page1)
         self.lhelp.SetPage(page)
-        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED,self.OnLinkClicked )
-        
+        self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)
         #open the help frame a the current page
-        if  pageToOpen!= None:
-            self.rhelp.LoadPage(str( pageToOpen))
-            
-        vbox.Add(self.rhelp,1, wx.EXPAND)
+        if  pageToOpen != None:
+            self.rhelp.LoadPage(str(pageToOpen))
+        vbox.Add(self.rhelp, 1, wx.EXPAND)
         vboxl.Add(self.lhelp, 1, wx.EXPAND)
         rpanel.SetSizer(vbox)
         lpanel.SetSizer(vboxl)
         lpanel.SetFocus()
-        
         vbox1 = wx.BoxSizer(wx.HORIZONTAL)
-        vbox1.Add(splitter,1,wx.EXPAND)
+        vbox1.Add(splitter, 1, wx.EXPAND)
         splitter.AppendWindow(lpanel, 200)
         splitter.AppendWindow(rpanel)
         self.SetSizer(vbox1)
-       
         self.Centre()
         self.Show(True)
Index: theoryview/perspectives/theory/model_panel.py
===================================================================
--- theoryview/perspectives/theory/model_panel.py	(revision d7b7156f5e3396b66f5f4b5c4a366e887b25df32)
+++ theoryview/perspectives/theory/model_panel.py	(revision 2f60121365e0ece9b765fb57a132cf4e4b3a15a4)
@@ -5,16 +5,18 @@
 import copy
 import math
-from sans.models.dispersion_models import ArrayDispersion, GaussianDispersion
-
+from sans.guiframe.panel_base import PanelBase
+from sans.models.dispersion_models import ArrayDispersion
+from sans.models.dispersion_models import GaussianDispersion
 from sans.guicomm.events import StatusEvent   
 from sans.guiframe.utils import format_number
-(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
-_BOX_WIDTH = 76
-
 import basepage
 from basepage import BasicPage
 from basepage import PageInfoEvent
-
-class ModelPanel(BasicPage):
+(ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
+
+_BOX_WIDTH = 76
+
+
+class ModelPanel(BasicPage, PanelBase):
     """
     FitPanel class contains fields allowing to display results when
@@ -30,6 +32,8 @@
     ## Title to appear on top of the window
     window_caption = "Theory Model"
-    def __init__(self,parent, page_info, model_list_box):
-        BasicPage.__init__(self, parent, page_info , model_list_box)
+    
+    def __init__(self, parent, page_info, model_list_box):
+        BasicPage.__init__(self, parent, page_info, model_list_box)
+        PanelBase.__init__(self)
         """ 
         Initialization of the Panel
@@ -38,12 +42,9 @@
         self._fill_range_sizer()
         self.engine_type = None 
-         
-        description=""
-        if self.model!=None:
-            
+        description = ""
+        if self.model != None:
             description = self.model.description
-            
             self.select_model(self.model)
-            self.set_model_description(description,self.sizer2)
+            self.set_model_description(description, self.sizer2)
             
     def _on_display_description(self, event):
@@ -55,6 +56,5 @@
         """
         self._on_display_description_helper()
-        
-        self.SetScrollbars(20,20,25,65)
+        self.SetScrollbars(20, 20, 25, 65)
         self.Refresh()
 
@@ -69,16 +69,14 @@
         if self.description_hide.GetValue():
             self.sizer_description.Clear(True)
-            
         else:
             description="Model contains no description"
-            if self.model!=None:
+            if self.model != None:
                 description = self.model.description
-            if description.lstrip().rstrip() =="": 
+            if description.lstrip().rstrip() == "": 
                 description="Model contains no description"
-            self.description = wx.StaticText( self,-1,str(description) )
-            self.sizer_description.Add( self.description, 1, wx.EXPAND | wx.ALL, 10 )
-           
+            self.description = wx.StaticText(self, -1, str(description))
+            self.sizer_description.Add(self.description, 1, 
+                                       wx.EXPAND|wx.ALL, 10)
         self.Layout()
-    
     
     def _fill_range_sizer(self):
@@ -90,18 +88,18 @@
         ##The following 3 lines are for Mac. Let JHC know before modifying..
         title = "Plotted Q Range"
-        box_description= wx.StaticBox(self, -1,str(title))
+        box_description = wx.StaticBox(self, -1, str(title))
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
 
-        sizer_npts= wx.GridSizer(1, 1,5, 5)    
-        self.npts    = self.ModelTextCtrl(self, -1,size=(_BOX_WIDTH,20), style=wx.TE_PROCESS_ENTER)
+        sizer_npts= wx.GridSizer(1, 1, 5, 5)    
+        self.npts    = self.ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20), 
+                                          style=wx.TE_PROCESS_ENTER)
         self.npts.SetValue(format_number(self.num_points))
         self.npts.SetToolTipString("Number of point to plot.")
-        
-        sizer_npts.Add(wx.StaticText(self, -1, 'Npts'),1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 13)        
-
-        sizer_npts.Add(self.npts,1,wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
-        self._set_range_sizer( title=title, box_sizer=boxsizer1, object= sizer_npts)
-       
-       
+        sizer_npts.Add(wx.StaticText(self, -1, 'Npts'), 1, 
+                       wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 13)        
+        sizer_npts.Add(self.npts, 1, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) 
+        self._set_range_sizer(title=title, box_sizer=boxsizer1, 
+                              object=sizer_npts)
+    
     def _on_select_model(self, event): 
         """
@@ -114,5 +112,4 @@
         self.select_model(self.model)
         
-       
     def _fill_model_sizer(self, sizer):
         """
@@ -122,16 +119,14 @@
         ##The following 3 lines are for Mac. Let JHC know before modifying..
         title = "Model"
-        box_description= wx.StaticBox(self, -1,str(title))
+        box_description = wx.StaticBox(self, -1, str(title))
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-        
         id = wx.NewId()
-        self.model_view =wx.Button(self,id,'View 2D', size=(80,23))
-        self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D,id=id)
+        self.model_view = wx.Button(self, id,'View 2D', size=(80, 23))
+        self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id)
         self.model_view.SetToolTipString("View model in 2D")
-        
         ## class base method  to add view 2d button   
-        self._set_model_sizer(sizer=sizer,box_sizer=boxsizer1, title=title,object= self.model_view )    
-    
-  
+        self._set_model_sizer(sizer=sizer, box_sizer=boxsizer1, 
+                              title=title, object=self.model_view)    
+    
     #def _set_sizer_gaussian(self):
     def _set_sizer_dispersion(self, dispersity):
@@ -140,11 +135,10 @@
         
         """
-        self.fittable_param=[]
-        self.fixed_param=[]
-        self.orientation_params_disp=[]
+        self.fittable_param = []
+        self.fixed_param = []
+        self.orientation_params_disp = []
         #self.temp=[]
-       
         self.sizer4_4.Clear(True)
-        if self.model==None:
+        if self.model == None:
             ##no model is selected
             return
@@ -159,44 +153,43 @@
             self._disp_obj_dict[item] = disp_model
             self.model.set_dispersion(item, disp_model)
-            self.state._disp_obj_dict[item]= disp_model
-            
-            
-        ix=0
-        iy=1
+            self.state._disp_obj_dict[item] = disp_model
+        ix = 0
+        iy = 1
         disp = wx.StaticText(self, -1, ' ')
-        self.sizer4_4.Add(disp,( iy, ix),(1,1), 
+        self.sizer4_4.Add(disp,(iy, ix), (1, 1), 
                            wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
         ix += 1 
         values = wx.StaticText(self, -1, 'Sigma [A]')
-        values.SetToolTipString(\
-        "Sigma(STD) in the A unit; the standard deviation from the mean value.")
-
-        self.sizer4_4.Add(values,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 
-                          0)
-       
+        hint_msg = "Sigma(STD) in the A unit; the standard "
+        hint_msg += "deviation from the mean value."
+        values.SetToolTipString(hint_msg)
+        self.sizer4_4.Add(values, (iy, ix), (1, 1), 
+                          wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         ix += 1 
         npts = wx.StaticText(self, -1, 'Npts')
-        npts.SetToolTipString("Number of sampling points for the numerical\n\
-        integration over the distribution function.")
-        self.sizer4_4.Add(npts,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        hint_msg = "Number of sampling points for the numerical\n"
+        hint_msg += "integration over the distribution function."
+        npts.SetToolTipString(hint_msg)
+        self.sizer4_4.Add(npts, (iy, ix), (1, 1),
+                          wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         ix += 1 
         nsigmas = wx.StaticText(self, -1, 'Nsigmas')
-        nsigmas.SetToolTipString("   Number of sigmas between which the range\n\
-         of the distribution function will be used for weighting. \n\
-        The value '3' covers 99.5% for Gaussian distribution \n\
-        function.")
-        self.sizer4_4.Add(nsigmas,( iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE,
-                           0)
-         
+        hint_msg = "Number of sigmas between which the range\n"
+        hint_msg += "of the distribution function will be used for "
+        hint_msg += "weighting.\n The value '3' covers 99.5% for Gaussian "
+        hint_msg += "  distribution \n function."
+        nsigmas.SetToolTipString(hint_msg)
+        self.sizer4_4.Add(nsigmas, (iy, ix), 
+                          (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         for item in self.model.dispersion.keys():
             if not item in self.model.orientation_params:
-                self.disp_cb_dict[item]= None
-                name0="Distribution of " + item
-                name1=item+".width"
+                self.disp_cb_dict[item] = None
+                name0 = "Distribution of " + item
+                name1 = item + ".width"
                 name2=item+".npts"
                 name3=item+".nsigmas"
                 iy += 1
                 for p in self.model.dispersion[item].keys():
-                    if p=="width":
+                    if p == "width":
                         ix = 0
                         name = wx.StaticText(self, -1,  name0)
@@ -489,11 +482,12 @@
 
         sizer_selection=wx.BoxSizer(wx.HORIZONTAL)
-        self.description_hide = wx.RadioButton(self, -1, 'Hide', style=wx.RB_GROUP)
+        self.description_hide = wx.RadioButton(self, -1, 'Hide', 
+                                               style=wx.RB_GROUP)
         self.description_show = wx.RadioButton(self, -1, 'Show')
        
         
-        if description=="":
+        if description == "":
             self.description_hide.SetValue(True)
-            description=" Description unavailable. Click for details"
+            description = " Description unavailable. Click for details"
             
         self.description = wx.StaticText( self,-1,str(description) )
Index: theoryview/perspectives/theory/theory.py
===================================================================
--- theoryview/perspectives/theory/theory.py	(revision 9e2cfeefbe130c9c954c8c6405d7ebb6e1b34609)
+++ theoryview/perspectives/theory/theory.py	(revision 2f60121365e0ece9b765fb57a132cf4e4b3a15a4)
@@ -9,5 +9,6 @@
 import model_panel
 from model_panel import ModelPanel
-from sans.guicomm.events import NewPlotEvent, StatusEvent 
+from sans.guicomm.events import NewPlotEvent
+from sans.guicomm.events import StatusEvent 
 from sans.guiframe.dataFitting import Data2D
 from sans.guiframe.dataFitting import Theory1D
@@ -17,4 +18,5 @@
 DEFAULT_QMAX = 0.13
 DEFAULT_NPTS = 50
+
 
 class PlotInfo:
@@ -32,5 +34,7 @@
     info= None
     
-class Plugin:
+from sans.guiframe.plugin_base import PluginBase  
+
+class Plugin(PluginBase):
     """
     This class defines the interface for a Plugin class
@@ -40,17 +44,6 @@
     
     def __init__(self, standalone=True):
-        """
-        Abstract class for gui_manager Plugins.
-        
-        """
-        ## Plug-in name. It will appear on the application menu.
-        self.sub_menu = "Theory"        
-        
-        ## Reference to the parent window. Filled by get_panels() below.
-        self.parent = None
-        
-        ## List of panels that you would like to open in AUI windows
-        #  for your plug-in. This defines your plug-in "perspective"
-        self.perspective = []
+        PluginBase.__init__(self, name="Theory", standalone=standalone)
+        
         # Log startup
         logging.info("Theory plug-in started")   
@@ -59,19 +52,7 @@
         self.menu_mng = models.ModelManager()
         # reference to the current running thread
-        self.calc_2D= None
-        self.calc_1D= None
-        
-    def populate_menu(self, id, owner):
-        """
-        Create and return the list of application menu
-        items for the plug-in. 
-        
-        :param id: deprecated. Un-used.
-        :param parent: parent window
-        
-        :return: plug-in menu
-        """
-        return []
-      
+        self.calc_2D = None
+        self.calc_1D = None
+   
     def get_panels(self, parent):
         """
@@ -99,53 +80,5 @@
         return [self.model_panel]
     
-    def get_context_menu(self, graph=None):
-        """
-        This method is optional.
-    
-        When the context menu of a plot is rendered, the 
-        get_context_menu method will be called to give you a 
-        chance to add a menu item to the context menu.
-        
-        A ref to a Graph object is passed so that you can
-        investigate the plot content and decide whether you
-        need to add items to the context menu.  
-        
-        This method returns a list of menu items.
-        Each item is itself a list defining the text to 
-        appear in the menu, a tool-tip help text, and a
-        call-back method.
-        
-        :param graph: the Graph object to which we attach the context menu
-        
-        :return: a list of menu items with call-back function
-        
-        """
-        return []    
-    
-    def get_perspective(self):
-        """
-        Get the list of panel names for this perspective
-        
-        """
-        return self.perspective
-    
-    def on_perspective(self, event):
-        """
-        Call back function for the perspective menu item.
-        We notify the parent window that the perspective
-        has changed.
-        
-        :param event: menu event
-        
-        """
-        self.parent.set_perspective(self.perspective)
-    
-    def post_init(self):
-        """
-        Post initialization call back to close the loose ends
-        
-        """
-        pass
-            
+   
     def draw_model(self, model, data= None,smearer= None,
                    enable1D= True, enable2D= False,
