Index: src/sas/perspectives/calculator/model_editor.py
===================================================================
--- src/sas/perspectives/calculator/model_editor.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/calculator/model_editor.py	(revision 49ab5d718dd7743a6a296e666dfb643183bc969d)
@@ -28,5 +28,5 @@
 _BOX_WIDTH = 55
 
-    
+
 def _compileFile(path):
     """
@@ -40,5 +40,5 @@
         _, value, _ = sys.exc_info()
         return value
-    
+
 def _deleteFile(path):
     """
@@ -50,16 +50,16 @@
         raise
 
- 
+
 class TextDialog(wx.Dialog):
     """
-    Dialog for easy custom sum models  
+    Dialog for easy custom sum models
     """
-    def __init__(self, parent=None, base=None, id=None, title='', 
+    def __init__(self, parent=None, base=None, id=None, title='',
                  model_list=[], plugin_dir=None):
         """
-        Dialog window popup when selecting 'Easy Custom Sum/Multiply' 
+        Dialog window popup when selecting 'Easy Custom Sum/Multiply'
         on the menu
         """
-        wx.Dialog.__init__(self, parent=parent, id=id, 
+        wx.Dialog.__init__(self, parent=parent, id=id,
                            title=title, size=(PNL_WIDTH, PNL_HITE))
         self.parent = base
@@ -102,5 +102,5 @@
         self.good_name = True
         self.fill_oprator_combox()
-        
+
     def _layout_name(self):
         """
@@ -110,6 +110,6 @@
         self.name_hsizer = wx.BoxSizer(wx.HORIZONTAL)
         #title name [string]
-        name_txt = wx.StaticText(self, -1, 'Function Name : ')  
-        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 
+        name_txt = wx.StaticText(self, -1, 'Function Name : ')
+        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH * 3 / 5, -1))
         self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name)
         self.name_tcl.SetValue('')
@@ -117,11 +117,11 @@
         hint_name = "Unique Sum/Multiply Model Function Name."
         self.name_tcl.SetToolTipString(hint_name)
-        self.name_hsizer.AddMany([(name_txt, 0, wx.LEFT|wx.TOP, 10),
-                            (self.name_tcl, -1, 
-                             wx.EXPAND|wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])
-        self.name_sizer.AddMany([(self.name_hsizer, -1, 
-                                        wx.LEFT|wx.TOP, 10)])
-        
-        
+        self.name_hsizer.AddMany([(name_txt, 0, wx.LEFT | wx.TOP, 10),
+                            (self.name_tcl, -1,
+                             wx.EXPAND | wx.RIGHT | wx.TOP | wx.BOTTOM, 10)])
+        self.name_sizer.AddMany([(self.name_hsizer, -1,
+                                        wx.LEFT | wx.TOP, 10)])
+
+
     def _layout_description(self):
         """
@@ -130,14 +130,14 @@
         self.desc_sizer = wx.BoxSizer(wx.HORIZONTAL)
         #title name [string]
-        desc_txt = wx.StaticText(self, -1, 'Description (optional) : ')  
-        self.desc_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 
+        desc_txt = wx.StaticText(self, -1, 'Description (optional) : ')
+        self.desc_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH * 3 / 5, -1))
         self.desc_tcl.SetValue('')
         #self.name_tcl.SetFont(self.font)
         hint_desc = "Write a short description of this model function."
         self.desc_tcl.SetToolTipString(hint_desc)
-        self.desc_sizer.AddMany([(desc_txt, 0, wx.LEFT|wx.TOP, 10),
-                                (self.desc_tcl, -1, 
-                                wx.EXPAND|wx.RIGHT|wx.TOP|wx.BOTTOM, 10)])     
-  
+        self.desc_sizer.AddMany([(desc_txt, 0, wx.LEFT | wx.TOP, 10),
+                                (self.desc_tcl, -1,
+                                wx.EXPAND | wx.RIGHT | wx.TOP | wx.BOTTOM, 10)])
+
     def _build_sizer(self):
         """
@@ -145,42 +145,42 @@
         """
         box_width = 195 # combobox width
-        vbox  = wx.BoxSizer(wx.VERTICAL)
+        vbox = wx.BoxSizer(wx.VERTICAL)
         self.sizer = wx.GridBagSizer(1, 3)
         self._layout_name()
         self._layout_description()
-        
-        
-        sum_description = wx.StaticBox(self, -1, 'Select', 
-                                       size=(PNL_WIDTH-30, 70))
+
+
+        sum_description = wx.StaticBox(self, -1, 'Select',
+                                       size=(PNL_WIDTH - 30, 70))
         sum_box = wx.StaticBoxSizer(sum_description, wx.VERTICAL)
         model1_box = wx.BoxSizer(wx.HORIZONTAL)
         model2_box = wx.BoxSizer(wx.HORIZONTAL)
         model_vbox = wx.BoxSizer(wx.VERTICAL)
-        self.model1 =  wx.ComboBox(self, -1, style=wx.CB_READONLY)
+        self.model1 = wx.ComboBox(self, -1, style=wx.CB_READONLY)
         wx.EVT_COMBOBOX(self.model1, -1, self.on_model1)
-        self.model1.SetMinSize((box_width*5/6, -1))
+        self.model1.SetMinSize((box_width * 5 / 6, -1))
         self.model1.SetToolTipString("model1")
-        
-        self.operator_cbox = wx.ComboBox(self, -1, size=(50, -1), 
+
+        self.operator_cbox = wx.ComboBox(self, -1, size=(50, -1),
                                          style=wx.CB_READONLY)
         wx.EVT_COMBOBOX(self.operator_cbox, -1, self.on_select_operator)
         operation_tip = "Add: +, Multiply: * "
         self.operator_cbox.SetToolTipString(operation_tip)
-        
-        self.model2 =  wx.ComboBox(self, -1, style=wx.CB_READONLY)
+
+        self.model2 = wx.ComboBox(self, -1, style=wx.CB_READONLY)
         wx.EVT_COMBOBOX(self.model2, -1, self.on_model2)
-        self.model2.SetMinSize((box_width*5/6, -1))
+        self.model2.SetMinSize((box_width * 5 / 6, -1))
         self.model2.SetToolTipString("model2")
         self._set_model_list()
-        
+
          # Buttons on the bottom
         self.static_line_1 = wx.StaticLine(self, -1)
-        self.okButton = wx.Button(self,wx.ID_OK, 'Apply', size=(box_width/2, 25))
+        self.okButton = wx.Button(self, wx.ID_OK, 'Apply', size=(box_width / 2, 25))
         self.okButton.Bind(wx.EVT_BUTTON, self.check_name)
-        self.closeButton = wx.Button(self,wx.ID_CANCEL, 'Close', 
-                                     size=(box_width/2, 25))
+        self.closeButton = wx.Button(self, wx.ID_CANCEL, 'Close',
+                                     size=(box_width / 2, 25))
         # Intro
-        self.explanation  = "  custom model = %s %s "% (self.factor, '*')
-        self.explanation  += "(model1 %s model2)\n"% self.operator
+        self.explanation = "  custom model = %s %s " % (self.factor, '*')
+        self.explanation += "(model1 %s model2)\n" % self.operator
         #explanation  += "  Note: This will overwrite the previous sum model.\n"
         model_string = " Model%s (p%s):"
@@ -196,8 +196,8 @@
         self.explanationctr = wx.StaticText(self, -1, self.explanation)
         self.sizer.Add(self.explanationctr , (iy, ix),
-                 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        model1_box.Add(wx.StaticText(self, -1, model_string% (1, 1)), -1, 0)
-        model1_box.Add((box_width-15, 10))
-        model1_box.Add(wx.StaticText(self, -1, model_string% (2, 2)), -1, 0)
+                 (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        model1_box.Add(wx.StaticText(self, -1, model_string % (1, 1)), -1, 0)
+        model1_box.Add((box_width - 15, 10))
+        model1_box.Add(wx.StaticText(self, -1, model_string % (2, 2)), -1, 0)
         model2_box.Add(self.model1, -1, 0)
         model2_box.Add((15, 10))
@@ -211,20 +211,20 @@
         ix = 0
         self.sizer.Add(sum_box, (iy, ix),
-                  (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                  (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         vbox.Add((10, 10))
         vbox.Add(self.static_line_1, 0, wx.EXPAND, 10)
-        vbox.Add(self.msg_sizer, 0, 
-                 wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE|wx.BOTTOM, 10)
+        vbox.Add(self.msg_sizer, 0,
+                 wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE | wx.BOTTOM, 10)
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(self.okButton, 0, 
-                         wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(self.okButton, 0,
+                         wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 0)
         sizer_button.Add(self.closeButton, 0,
-                          wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
-         
+                          wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
+
         self.SetSizer(vbox)
         self.Centre()
-        
+
     def on_change_name(self, event=None):
         """
@@ -235,5 +235,5 @@
         self.name_tcl.SetBackgroundColour('white')
         self.Refresh()
-    
+
     def check_name(self, event=None):
         """
@@ -264,5 +264,5 @@
                 info = 'Error'
                 msg = "Name exists already."
-                wx.MessageBox(msg, info)  
+                wx.MessageBox(msg, info)
                 self._notes = msg
                 color = 'red'
@@ -278,5 +278,5 @@
         self.on_apply(self.fname)
         return self.good_name
-    
+
     def on_apply(self, path):
         """
@@ -295,5 +295,5 @@
             color = 'blue'
         except:
-            msg= "Easy Custom Sum/Multipy: Error occurred..."
+            msg = "Easy Custom Sum/Multipy: Error occurred..."
             info = 'Error'
             color = 'red'
@@ -301,10 +301,10 @@
         self._msg_box.SetForegroundColour(color)
         if self.parent.parent != None:
-            from sas.guiframe.events import StatusEvent 
-            wx.PostEvent(self.parent.parent, StatusEvent(status = msg, 
+            from sas.guiframe.events import StatusEvent
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg,
                                                       info=info))
         else:
             raise
-                  
+
     def _set_model_list(self):
         """
@@ -328,9 +328,9 @@
             list.sort()
         for idx in range(len(list)):
-            self.model1.Append(str(list[idx]), idx) 
+            self.model1.Append(str(list[idx]), idx)
             self.model2.Append(str(list[idx]), idx)
         self.model1.SetStringSelection(self.model1_string)
         self.model2.SetStringSelection(self.model2_string)
-    
+
     def update_cm_list(self):
         """
@@ -344,6 +344,6 @@
                 name = str(c_name.split('.')[0])
                 cm_list.append(name)
-        self.cm_list = cm_list 
-              
+        self.cm_list = cm_list
+
     def on_model1(self, event):
         """
@@ -358,5 +358,5 @@
         else:
             self.is_p1_custom = False
-            
+
     def on_model2(self, event):
         """
@@ -371,5 +371,5 @@
         else:
             self.is_p2_custom = False
-        
+
     def on_select_operator(self, event=None):
         """
@@ -379,5 +379,5 @@
         if event != None:
             event.Skip()
-        name = ''    
+        name = ''
         item = event.GetEventObject()
         text = item.GetValue()
@@ -393,14 +393,14 @@
         self.factor = factor
         self.operator = text
-        self.explanation = "  Custom Model = %s %s (model1 %s model2)\n"% \
+        self.explanation = "  Custom Model = %s %s (model1 %s model2)\n" % \
                     (self.factor, f_oper, self.operator)
         self.explanationctr.SetLabel(self.explanation)
-        self.name = name + M_NAME 
+        self.name = name + M_NAME
         self.sizer.Layout()
-             
+
     def fill_oprator_combox(self):
         """
         fill the current combobox with the operator
-        """   
+        """
         operator_list = [' +', ' *']
         for oper in operator_list:
@@ -408,5 +408,5 @@
             self.operator_cbox.SetClientData(pos, str(oper.strip()))
         self.operator_cbox.SetSelection(0)
-            
+
     def getText(self):
         """
@@ -414,10 +414,10 @@
         """
         return [self.model1_name, self.model2_name]
-    
+
     def write_string(self, fname, name1, name2):
         """
         Write and Save file
         """
-        self.fname = fname  
+        self.fname = fname
         description = self.desc_tcl.GetValue().lstrip().rstrip()
         if description == '':
@@ -435,5 +435,5 @@
         path = self.fname
         try:
-            out_f =  open(path,'w')
+            out_f = open(path, 'w')
         except :
             raise
@@ -488,5 +488,5 @@
         #else:
         #    msg = "Name exists already."
-        
+
     def compile_file(self, path):
         """
@@ -495,5 +495,5 @@
         path = self.fname
         _compileFile(path)
-        
+
     def delete_file(self, path):
         """
@@ -535,8 +535,8 @@
         #self.bt_apply.Disable()
 
-             
+
     def _define_structure(self):
         """
-        define initial sizer 
+        define initial sizer
         """
         #w, h = self.parent.GetSize()
@@ -550,5 +550,5 @@
         self.button_sizer = wx.BoxSizer(wx.HORIZONTAL)
         self.msg_sizer = wx.BoxSizer(wx.HORIZONTAL)
-        
+
     def _layout_name(self):
         """
@@ -556,5 +556,5 @@
         """
         #title name [string]
-        name_txt = wx.StaticText(self, -1, 'Function Name : ')  
+        name_txt = wx.StaticText(self, -1, 'Function Name : ')
         overwrite_cb = wx.CheckBox(self, -1, "Overwrite?", (10, 10))
         overwrite_cb.SetValue(False)
@@ -562,5 +562,5 @@
         wx.EVT_CHECKBOX(self, overwrite_cb.GetId(), self.on_over_cb)
         #overwrite_cb.Show(False)
-        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 
+        self.name_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH * 3 / 5, -1))
         self.name_tcl.Bind(wx.EVT_TEXT_ENTER, self.on_change_name)
         self.name_tcl.SetValue('MyFunction')
@@ -568,11 +568,11 @@
         hint_name = "Unique Model Function Name."
         self.name_tcl.SetToolTipString(hint_name)
-        self.name_hsizer.AddMany([(self.name_tcl, 0, wx.LEFT|wx.TOP, 0),
+        self.name_hsizer.AddMany([(self.name_tcl, 0, wx.LEFT | wx.TOP, 0),
                                        (overwrite_cb, 0, wx.LEFT, 20)])
-        self.name_sizer.AddMany([(name_txt, 0, wx.LEFT|wx.TOP, 10),
-                                       (self.name_hsizer, 0, 
-                                        wx.LEFT|wx.TOP|wx.BOTTOM, 10)])
-        
-        
+        self.name_sizer.AddMany([(name_txt, 0, wx.LEFT | wx.TOP, 10),
+                                       (self.name_hsizer, 0,
+                                        wx.LEFT | wx.TOP | wx.BOTTOM, 10)])
+
+
     def _layout_description(self):
         """
@@ -580,37 +580,37 @@
         """
         #title name [string]
-        desc_txt = wx.StaticText(self, -1, 'Description (optional) : ')  
-        self.desc_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH*3/5, -1)) 
+        desc_txt = wx.StaticText(self, -1, 'Description (optional) : ')
+        self.desc_tcl = wx.TextCtrl(self, -1, size=(PANEL_WIDTH * 3 / 5, -1))
         self.desc_tcl.SetValue('')
         #self.name_tcl.SetFont(self.font)
         hint_desc = "Write a short description of the model function."
         self.desc_tcl.SetToolTipString(hint_desc)
-        self.desc_sizer.AddMany([(desc_txt, 0, wx.LEFT|wx.TOP, 10),
-                                       (self.desc_tcl, 0, 
-                                        wx.LEFT|wx.TOP|wx.BOTTOM, 10)])     
+        self.desc_sizer.AddMany([(desc_txt, 0, wx.LEFT | wx.TOP, 10),
+                                       (self.desc_tcl, 0,
+                                        wx.LEFT | wx.TOP | wx.BOTTOM, 10)])
     def _layout_param(self):
         """
         Do the layout for parameter related widgets
         """
-        param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ') 
-        
+        param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ')
+
         param_tip = "#Set the parameters and initial values.\n"
         param_tip += "#Example:\n"
         param_tip += "A = 1\nB = 1"
         #param_txt.SetToolTipString(param_tip)
-        id  = wx.NewId() 
-        self.param_tcl = EditWindow(self, id, wx.DefaultPosition, 
-                            wx.DefaultSize, wx.CLIP_CHILDREN|wx.SUNKEN_BORDER)
+        id = wx.NewId()
+        self.param_tcl = EditWindow(self, id, wx.DefaultPosition,
+                            wx.DefaultSize, wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)
         self.param_tcl.setDisplayLineNumbers(True)
         self.param_tcl.SetToolTipString(param_tip)
 
         self.param_sizer.AddMany([(param_txt, 0, wx.LEFT, 10),
-                        (self.param_tcl, 1, wx.EXPAND|wx.ALL, 10)])
-                
+                        (self.param_tcl, 1, wx.EXPAND | wx.ALL, 10)])
+
     def _layout_function(self):
         """
         Do the layout for function related widgets
         """
-        function_txt = wx.StaticText(self, -1, 'Function(x) : ') 
+        function_txt = wx.StaticText(self, -1, 'Function(x) : ')
         hint_function = "#Example:\n"
         hint_function += "if x <= 0:\n"
@@ -621,11 +621,11 @@
         math_txt = wx.StaticText(self, -1, '*Useful math functions: ')
         math_combo = self._fill_math_combo()
-        
-        id  = wx.NewId() 
-        self.function_tcl = EditWindow(self, id, wx.DefaultPosition, 
-                            wx.DefaultSize, wx.CLIP_CHILDREN|wx.SUNKEN_BORDER)
+
+        id = wx.NewId()
+        self.function_tcl = EditWindow(self, id, wx.DefaultPosition,
+                            wx.DefaultSize, wx.CLIP_CHILDREN | wx.SUNKEN_BORDER)
         self.function_tcl.setDisplayLineNumbers(True)
         self.function_tcl.SetToolTipString(hint_function)
-        
+
         self.func_horizon_sizer.Add(function_txt)
         self.func_horizon_sizer.Add(math_txt, 0, wx.LEFT, 250)
@@ -633,31 +633,31 @@
 
         self.function_sizer.Add(self.func_horizon_sizer, 0, wx.LEFT, 10)
-        self.function_sizer.Add( self.function_tcl, 1, wx.EXPAND|wx.ALL, 10)
-        
+        self.function_sizer.Add(self.function_tcl, 1, wx.EXPAND | wx.ALL, 10)
+
     def _layout_msg(self):
         """
         Layout msg
         """
-        self._msg_box = wx.StaticText(self, -1, self._notes, 
+        self._msg_box = wx.StaticText(self, -1, self._notes,
                                       size=(PANEL_WIDTH, -1))
-        self.msg_sizer.Add(self._msg_box, 0, wx.LEFT, 10)  
-                    
-    def _layout_button(self):  
+        self.msg_sizer.Add(self._msg_box, 0, wx.LEFT, 10)
+
+    def _layout_button(self):
         """
         Do the layout for the button widgets
-        """         
+        """
         self.bt_apply = wx.Button(self, -1, "Apply", size=(_BOX_WIDTH, -1))
         self.bt_apply.SetToolTipString("Save changes into the imported data.")
         self.bt_apply.Bind(wx.EVT_BUTTON, self.on_click_apply)
-        
+
         self.bt_close = wx.Button(self, -1, 'Close', size=(_BOX_WIDTH, -1))
         self.bt_close.Bind(wx.EVT_BUTTON, self.on_close)
         self.bt_close.SetToolTipString("Close this panel.")
-        
-        self.button_sizer.AddMany([(self.bt_apply, 0, 
+
+        self.button_sizer.AddMany([(self.bt_apply, 0,
                                     wx.LEFT, EDITOR_WIDTH * 0.8),
-                                   (self.bt_close, 0, 
-                                    wx.LEFT|wx.BOTTOM, 15)])
-          
+                                   (self.bt_close, 0,
+                                    wx.LEFT | wx.BOTTOM, 15)])
+
     def _do_layout(self):
         """
@@ -671,24 +671,24 @@
         self._layout_msg()
         self._layout_button()
-        self.main_sizer.AddMany([(self.name_sizer, 0,  
-                                        wx.EXPAND|wx.ALL, 5),
-                                 (wx.StaticLine(self), 0, 
-                                       wx.ALL|wx.EXPAND, 5),
-                                 (self.desc_sizer, 0,  
-                                        wx.EXPAND|wx.ALL, 5),
-                                 (wx.StaticLine(self), 0, 
-                                       wx.ALL|wx.EXPAND, 5),
+        self.main_sizer.AddMany([(self.name_sizer, 0,
+                                        wx.EXPAND | wx.ALL, 5),
+                                 (wx.StaticLine(self), 0,
+                                       wx.ALL | wx.EXPAND, 5),
+                                 (self.desc_sizer, 0,
+                                        wx.EXPAND | wx.ALL, 5),
+                                 (wx.StaticLine(self), 0,
+                                       wx.ALL | wx.EXPAND, 5),
                                 (self.param_sizer, 1,
-                                         wx.EXPAND|wx.ALL, 5),
-                                 (wx.StaticLine(self), 0, 
-                                       wx.ALL|wx.EXPAND, 5),
+                                         wx.EXPAND | wx.ALL, 5),
+                                 (wx.StaticLine(self), 0,
+                                       wx.ALL | wx.EXPAND, 5),
                                 (self.function_sizer, 2,
-                                         wx.EXPAND|wx.ALL, 5),
-                                 (wx.StaticLine(self), 0, 
-                                       wx.ALL|wx.EXPAND, 5),
-                                 (self.msg_sizer, 0, 
-                                        wx.EXPAND|wx.ALL, 5),
+                                         wx.EXPAND | wx.ALL, 5),
+                                 (wx.StaticLine(self), 0,
+                                       wx.ALL | wx.EXPAND, 5),
+                                 (self.msg_sizer, 0,
+                                        wx.EXPAND | wx.ALL, 5),
                                 (self.button_sizer, 0,
-                                         wx.EXPAND|wx.ALL, 5)])
+                                         wx.EXPAND | wx.ALL, 5)])
         self.SetSizer(self.main_sizer)
         self.SetAutoLayout(True)
@@ -698,17 +698,17 @@
         Fill up the math combo box
         """
-        self.math_combo = wx.ComboBox(self, -1, size=(100, -1), 
-                                      style=wx.CB_READONLY) 
+        self.math_combo = wx.ComboBox(self, -1, size=(100, -1),
+                                      style=wx.CB_READONLY)
         for item in dir(math):
             if item.count("_") < 1:
                 try:
-                    exec "float(math.%s)"% item
+                    exec "float(math.%s)" % item
                     self.math_combo.Append(str(item))
                 except:
-                    self.math_combo.Append(str(item) + "()" )
+                    self.math_combo.Append(str(item) + "()")
         self.math_combo.Bind(wx.EVT_COMBOBOX, self._on_math_select)
         self.math_combo.SetSelection(0)
         return self.math_combo
-        
+
     def _on_math_select(self, event):
         """
@@ -716,9 +716,9 @@
         """
         event.Skip()
-        label = self.math_combo.GetLabel() 
+        label = self.math_combo.GetLabel()
         self.function_tcl.SetFocus()
         # Put the text at the cursor position
         pos = self.function_tcl.GetCurrentPos()
-        self.function_tcl.InsertText(pos, label)  
+        self.function_tcl.InsertText(pos, label)
         # Put the cursor at appropriate postion
         length = len(label)
@@ -726,5 +726,5 @@
             length -= 1
         f_pos = pos + length
-        self.function_tcl.GotoPos(f_pos)   
+        self.function_tcl.GotoPos(f_pos)
 
     def get_notes(self):
@@ -733,5 +733,5 @@
         """
         return self._notes
-                 
+
     def on_change_name(self, event=None):
         """
@@ -742,5 +742,5 @@
         self.name_tcl.SetBackgroundColour('white')
         self.Refresh()
-    
+
     def check_name(self):
         """
@@ -766,5 +766,5 @@
         self._notes += "to %s. \n" % str(s_title)
         return True
-    
+
     def on_over_cb(self, event):
         """
@@ -775,7 +775,7 @@
         cb = event.GetEventObject()
         self.overwrite_name = cb.GetValue()
-        
+
     def on_click_apply(self, event):
-        """   
+        """
         Changes are saved in data object imported to edit
         """
@@ -791,7 +791,7 @@
             func_str = self.function_tcl.GetText()
             # No input for the model function
-            if func_str.lstrip().rstrip():     
+            if func_str.lstrip().rstrip():
                 if func_str.count('return') > 0:
-                    self.write_file(self.fname, description, param_str, 
+                    self.write_file(self.fname, description, param_str,
                                                                     func_str)
                     tr_msg = _compileFile(self.fname)
@@ -800,5 +800,5 @@
                     if msg:
                         msg.replace("  ", "\n")
-                        msg +=  "\nCompiling Failed"
+                        msg += "\nCompiling Failed"
                 else:
                     msg = "Error: The func(x) must 'return' a value at least.\n"
@@ -811,15 +811,15 @@
         if self.base != None and not msg:
             self.base.update_custom_combo()
-            Model  = None
-            exec "from %s import Model"% name 
+            Model = None
+            exec "from %s import Model" % name
             try:
-                Model().run(0.01) 
+                Model().run(0.01)
             except:
                 msg = "Error "
                 _, value, _ = sys.exc_info()
-                msg += "in %s:\n%s\n" % (name,  value)
+                msg += "in %s:\n%s\n" % (name, value)
         if msg:
             info = 'Error'
-            color = 'red' 
+            color = 'red'
             try:
                 # try to remove pyc file if exists
@@ -843,21 +843,21 @@
         # Send msg to the top window  
         if self.base != None:
-                from sas.guiframe.events import StatusEvent 
-                wx.PostEvent(self.base.parent, StatusEvent(status = msg, 
+                from sas.guiframe.events import StatusEvent
+                wx.PostEvent(self.base.parent, StatusEvent(status=msg,
                                                       info=info))
         self.warning = msg
 
-                
-    def write_file(self, fname, desc_str, param_str, func_str):  
+
+    def write_file(self, fname, desc_str, param_str, func_str):
         """
         Write content in file
-        
+
         :param fname: full file path
         :param desc_str: content of the description strings
-        :param param_str: content of params; Strings  
+        :param param_str: content of params; Strings
         :param func_str: content of func; Strings
-        """ 
+        """
         try:
-            out_f =  open(fname,'w')
+            out_f = open(fname, 'w')
         except :
             raise
@@ -890,11 +890,11 @@
                 des0 = self.name + "\\n"
                 desc = str(desc_str.lstrip().rstrip().replace('\"', ''))
-                out_f.write(line% (des0 + desc) + "\n")
+                out_f.write(line % (des0 + desc) + "\n")
             elif line.count("def function(self, x=0.0%s):"):
                 if self.is_2d:
                     y_str = ', y=0.0'
-                    out_f.write(line% y_str + "\n")
+                    out_f.write(line % y_str + "\n")
                 else:
-                    out_f.write(line% '' + "\n")
+                    out_f.write(line % '' + "\n")
             elif line.count("#function here"):
                 for func_line in func_str.split('\n'):
@@ -906,5 +906,5 @@
                     if self.is_2d:
                         dep_var = 'z'
-                    out_f.write(spaces + 'return %s'% dep_var + "\n")
+                    out_f.write(spaces + 'return %s' % dep_var + "\n")
             elif line.count("#import scipy?"):
                 if has_scipy:
@@ -921,11 +921,11 @@
         for line in line_test:
             out_f.write(line + "\n")
-   
-        out_f.close() 
-    
-    def set_param_helper(self, line):   
+
+        out_f.close()
+
+    def set_param_helper(self, line):
         """
         Get string in line to define the params dictionary
-        
+
         :param line: one line of string got from the param_str
         """
@@ -941,12 +941,12 @@
             except:
                 value = 1.0 # default
-            params_str += spaces + "self.params['%s'] = %s\n"% (name, value)
-            
+            params_str += spaces + "self.params['%s'] = %s\n" % (name, value)
+
         return params_str
 
-    def set_function_helper(self, line):   
+    def set_function_helper(self, line):
         """
         Get string in line to define the local params
-        
+
         :param line: one line of string got from the param_str
         """
@@ -957,13 +957,13 @@
         for item in items:
             name = item.split("=")[0].lstrip().rstrip()
-            params_str += spaces + "%s = self.params['%s']\n"% (name, name)
+            params_str += spaces + "%s = self.params['%s']\n" % (name, name)
         return params_str
-    
+
     def get_warning(self):
         """
-        Get the warning msg 
+        Get the warning msg
         """
         return self.warning
-        
+
     def on_close(self, event):
         """
@@ -972,10 +972,10 @@
         self.parent.Show(False)#Close()
         event.Skip()
-        
+
 class EditorWindow(wx.Frame):
     """
     Editor Window
     """
-    def __init__(self, parent, base, path, title, 
+    def __init__(self, parent, base, path, title,
                  size=(EDITOR_WIDTH, EDITOR_HEIGTH), *args, **kwds):
         """
@@ -986,10 +986,10 @@
         wx.Frame.__init__(self, parent=None, *args, **kwds)
         self.parent = parent
-        self.panel = EditorPanel(parent=self, base=parent, 
+        self.panel = EditorPanel(parent=self, base=parent,
                                  path=path, title=title)
         self.Show(True)
         wx.EVT_CLOSE(self, self.OnClose)
-    
-    def OnClose(self, event):  
+
+    def OnClose(self, event):
         """
         On close event
@@ -1009,9 +1009,9 @@
 #import scipy?
 class Model(Model1DPlugin):
-    name = ""                             
+    name = ""
     def __init__(self):
-        Model1DPlugin.__init__(self, name=self.name)  
-        #set name same as file name 
-        self.name = self.get_fname()                                                   
+        Model1DPlugin.__init__(self, name=self.name)
+        #set name same as file name
+        self.name = self.get_fname()
         #self.params here
         self.description = "%s"
@@ -1064,7 +1064,7 @@
         return name
 ######################################################################
-## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!       
-if __name__ == "__main__": 
-    m= Model() 
+## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!!
+if __name__ == "__main__":
+    m= Model()
     out1 = m.runXY(0.0)
     out2 = m.runXY(0.01)
@@ -1085,11 +1085,11 @@
 from sas.models.pluginmodel import Model1DPlugin
 # User can change the name of the model (only with single functional model)
-#P1_model: 
+#P1_model:
 #from sas.models.%s import %s as P1
-#from %s import Model as P1 
-
-#P2_model: 
+#from %s import Model as P1
+
+#P2_model:
 #from sas.models.%s import %s as P2
-#from %s import Model as P2 
+#from %s import Model as P2
 import os
 import sys
@@ -1119,12 +1119,12 @@
         self.magnetic_params = []
         # non-fittable parameters
-        self.non_fittable = p_model1.non_fittable  
-        self.non_fittable += p_model2.non_fittable  
-            
-        ##models 
+        self.non_fittable = p_model1.non_fittable
+        self.non_fittable += p_model2.non_fittable
+
+        ##models
         self.p_model1= p_model1
         self.p_model2= p_model2
-        
-       
+
+
         ## dispersion
         self._set_dispersion()
@@ -1133,12 +1133,12 @@
         ## New parameter:scaling_factor
         self.params['scale_factor'] = %s
-        
+
         ## Parameter details [units, min, max]
         self._set_details()
         self.details['scale_factor'] = ['', None, None]
 
-        
+
         #list of parameter that can be fitted
-        self._set_fixed_params()  
+        self._set_fixed_params()
         ## parameters with orientation
         for item in self.p_model1.orientation_params:
@@ -1146,5 +1146,5 @@
             if not new_item in self.orientation_params:
                 self.orientation_params.append(new_item)
-            
+
         for item in self.p_model2.orientation_params:
             new_item = "p2_" + item
@@ -1156,5 +1156,5 @@
             if not new_item in self.magnetic_params:
                 self.magnetic_params.append(new_item)
-            
+
         for item in self.p_model2.magnetic_params:
             new_item = "p2_" + item
@@ -1172,8 +1172,8 @@
             multiplicity2 = 1
         ## functional multiplicity of the model
-        self.multiplicity1 = multiplicity1  
-        self.multiplicity2 = multiplicity2    
-        self.multiplicity_info = []   
-        
+        self.multiplicity1 = multiplicity1
+        self.multiplicity2 = multiplicity2
+        self.multiplicity_info = []
+
     def _clone(self, obj):
         obj.params     = copy.deepcopy(self.params)
@@ -1185,5 +1185,5 @@
         #obj = copy.deepcopy(self)
         return obj
-    
+
     def _get_name(self, name1, name2):
         p1_name = self._get_upper_name(name1)
@@ -1197,5 +1197,5 @@
         name += p2_name
         return name
-    
+
     def _get_upper_name(self, name=None):
         if name == None:
@@ -1207,19 +1207,19 @@
                 upper_name += str_name[index]
         return upper_name
-        
+
     def _set_dispersion(self):
-        ##set dispersion only from p_model 
+        ##set dispersion only from p_model
         for name , value in self.p_model1.dispersion.iteritems():
             #if name.lower() not in self.p_model1.orientation_params:
             new_name = "p1_" + name
-            self.dispersion[new_name]= value 
+            self.dispersion[new_name]= value
         for name , value in self.p_model2.dispersion.iteritems():
             #if name.lower() not in self.p_model2.orientation_params:
             new_name = "p2_" + name
-            self.dispersion[new_name]= value 
-            
-    def function(self, x=0.0): 
+            self.dispersion[new_name]= value
+
+    def function(self, x=0.0):
         return 0
-                               
+
     def getProfile(self):
         try:
@@ -1228,7 +1228,7 @@
             x = None
             y = None
-            
+
         return x, y
-    
+
     def _set_params(self):
         for name , value in self.p_model1.params.iteritems():
@@ -1237,5 +1237,5 @@
             new_name = "p1_" + name
             self.params[new_name]= value
-            
+
         for name , value in self.p_model2.params.iteritems():
             # No 2D-supported
@@ -1243,9 +1243,9 @@
             new_name = "p2_" + name
             self.params[new_name]= value
-                
+
         # Set "scale" as initializing
         self._set_scale_factor()
-      
-            
+
+
     def _set_details(self):
         for name ,detail in self.p_model1.details.iteritems():
@@ -1253,19 +1253,19 @@
             #if new_name not in self.orientation_params:
             self.details[new_name]= detail
-            
+
         for name ,detail in self.p_model2.details.iteritems():
             new_name = "p2_" + name
             #if new_name not in self.orientation_params:
             self.details[new_name]= detail
-    
+
     def _set_scale_factor(self):
         pass
-        
-                
+
+
     def setParam(self, name, value):
         # set param to this (p1, p2) model
         self._setParamHelper(name, value)
-        
-        ## setParam to p model 
+
+        ## setParam to p model
         model_pre = ''
         new_name = ''
@@ -1284,5 +1284,5 @@
         else:
             raise ValueError, "Model does not contain parameter %s" % name
-            
+
     def getParam(self, name):
         # Look for dispersion parameters
@@ -1300,7 +1300,7 @@
                 if item.lower()==name.lower():
                     return self.params[item]
-        return  
+        return
         #raise ValueError, "Model does not contain parameter %s" % name
-       
+
     def _setParamHelper(self, name, value):
         # Look for dispersion parameters
@@ -1319,8 +1319,8 @@
                     self.params[item] = value
                     return
-            
+
         raise ValueError, "Model does not contain parameter %s" % name
-             
-   
+
+
     def _set_fixed_params(self):
         for item in self.p_model1.fixed:
@@ -1332,17 +1332,17 @@
 
         self.fixed.sort()
-                
-                    
+
+
     def run(self, x = 0.0):
         self._set_scale_factor()
         return self.params['scale_factor'] %s \
 (self.p_model1.run(x) %s self.p_model2.run(x))
-    
+
     def runXY(self, x = 0.0):
         self._set_scale_factor()
         return self.params['scale_factor'] %s \
 (self.p_model1.runXY(x) %s self.p_model2.runXY(x))
-    
-    ## Now (May27,10) directly uses the model eval function 
+
+    ## Now (May27,10) directly uses the model eval function
     ## instead of the for-loop in Base Component.
     def evalDistribution(self, x = []):
@@ -1366,5 +1366,5 @@
             return value
         except:
-            raise 
+            raise
 
     def fill_description(self, p_model1, p_model2):
@@ -1373,22 +1373,22 @@
         description += "%s and %s. "% ( p_model1.name, p_model2.name )
         self.description += description
-          
+
     def get_fname(self):
         path = sys._getframe().f_code.co_filename
         basename  = os.path.basename(path)
         name, _ = os.path.splitext(basename)
-        return name     
-           
-if __name__ == "__main__": 
-    m1= Model() 
-    #m1.setParam("p1_scale", 25)  
+        return name
+
+if __name__ == "__main__":
+    m1= Model()
+    #m1.setParam("p1_scale", 25)
     #m1.setParam("p1_length", 1000)
-    #m1.setParam("p2_scale", 100) 
-    #m1.setParam("p2_rg", 100) 
+    #m1.setParam("p2_scale", 100)
+    #m1.setParam("p2_rg", 100)
     out1 = m1.runXY(0.01)
 
     m2= Model()
-    #m2.p_model1.setParam("scale", 25) 
-    #m2.p_model1.setParam("length", 1000) 
+    #m2.p_model1.setParam("scale", 25)
+    #m2.p_model1.setParam("length", 1000)
     #m2.p_model2.setParam("scale", 100)
     #m2.p_model2.setParam("rg", 100)
@@ -1401,5 +1401,5 @@
         print "===> Simple Test: Failed!"
 """
-      
+
 #if __name__ == "__main__": 
 #    app = wx.PySimpleApp()
@@ -1411,5 +1411,5 @@
     from sas.perspectives.fitting import models
     dir_path = models.find_plugins_dir()
-    app  = wx.App()
+    app = wx.App()
     window = EditorWindow(parent=None, base=None, path=dir_path, title="Editor")
-    app.MainLoop()         
+    app.MainLoop()
