Index: src/sas/perspectives/invariant/help_panel.py
===================================================================
--- src/sas/perspectives/invariant/help_panel.py	(revision b9a5f0eb8e8cbff8f8d934bbfa4ea18168141e13)
+++ src/sas/perspectives/invariant/help_panel.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -1,3 +1,5 @@
-#!/usr/bin/python
+"""
+    Help panel for Invariant perspective
+"""
 import wx
 import wx.html as html
@@ -5,7 +7,8 @@
 import os
 
-    
+
 class HelpDialog(wx.Dialog):
     """
+        Dialog box showing invariant panel help
     """
     def __init__(self, parent, id):
@@ -13,28 +16,28 @@
         """
         wx.Dialog.__init__(self, parent, id, size=(400, 420))
-        self.SetTitle("Invariant help") 
-        
+        self.SetTitle("Invariant help")
+
         vbox = wx.BoxSizer(wx.VERTICAL)
 
         explanation = help()
-           
+
         label_explain = wx.StaticText(self, -1, explanation, size=(350, 320))
-            
-        vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15)
+
+        vbox.Add(label_explain, 0, wx.ALL | wx.EXPAND, 15)
 
 
         static_line = wx.StaticLine(self, -1)
         vbox.Add(static_line, 0, wx.EXPAND, 0)
-        
+
         button_OK = wx.Button(self, wx.ID_OK, "OK")
 
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)       
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_OK, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
 
         self.SetSizer(vbox)
         self.SetAutoLayout(True)
-        
+
         self.Layout()
         self.Centre()
@@ -42,15 +45,16 @@
 class HelpWindow(wx.Frame):
     """
+        Help window for invariant perspective
     """
-    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=(820, 450))
         """
         contains help info
         """
-        self.SetTitle("Invariant Help") 
+        self.SetTitle("Invariant Help")
         splitter = MultiSplitterWindow(self, style=wx.SP_LIVE_UPDATE)
         rpanel = wx.Panel(splitter, -1)
         lpanel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN)
-        
+
         vbox = wx.BoxSizer(wx.VERTICAL)
         header = wx.Panel(rpanel, -1)
@@ -65,8 +69,8 @@
         header.SetSizer(hbox)
         vbox.Add(header, 0, wx.EXPAND)
-       
+
         vboxl = wx.BoxSizer(wx.VERTICAL)
         headerl = wx.Panel(lpanel, -1, size=(-1, 20))
-       
+
         headerl.SetBackgroundColour('#6666FF')
         headerl.SetForegroundColour('WHITE')
@@ -80,10 +84,10 @@
         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, 
+        self.rhelp = html.HtmlWindow(rpanel, -1, style=wx.NO_BORDER,
                                      size=(500, -1))
         import sas.perspectives.invariant as invariant
         path = invariant.get_data_path(media='media')
-        self.path = os.path.join(path,"invariant_help.html")
-     
+        self.path = os.path.join(path, "invariant_help.html")
+
         self.rhelp.LoadPage(self.path)
         page = """<html>
@@ -94,8 +98,8 @@
             </body>
             </html>""" % self.path
-        
+
         self.lhelp.SetPage(page)
         self.lhelp.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)
-        
+
         vbox.Add(self.rhelp, 1, wx.EXPAND)
         vboxl.Add(self.lhelp, 1, wx.EXPAND)
@@ -103,5 +107,5 @@
         lpanel.SetSizer(vboxl)
         lpanel.SetFocus()
-        
+
         vbox1 = wx.BoxSizer(wx.HORIZONTAL)
         vbox1.Add(splitter, 1, wx.EXPAND)
@@ -109,9 +113,9 @@
         splitter.AppendWindow(rpanel)
         self.SetSizer(vbox1)
-       
+
         self.Centre()
         self.Show(True)
-        
-        
+
+
     def OnLinkClicked(self, event):
         """
@@ -122,16 +126,18 @@
 class ViewApp(wx.App):
     """
+        Test application
     """
     def OnInit(self):
         """
+            Initialization for test application
         """
-        frame = HelpWindow(None, -1, 'HelpWindow')    
+        frame = HelpWindow(None, -1, 'HelpWindow')
         frame.Show(True)
         self.SetTopWindow(frame)
-        
+
         return True
-        
 
-if __name__ == "__main__": 
+
+if __name__ == "__main__":
     app = ViewApp(0)
-    app.MainLoop()     
+    app.MainLoop()
Index: src/sas/perspectives/invariant/invariant.py
===================================================================
--- src/sas/perspectives/invariant/invariant.py	(revision b9a5f0eb8e8cbff8f8d934bbfa4ea18168141e13)
+++ src/sas/perspectives/invariant/invariant.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -3,11 +3,11 @@
 
 ################################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
 #
-#See the license text in license.txt
+# See the license text in license.txt
 #
-#copyright 2009, University of Tennessee
+# copyright 2009, University of Tennessee
 ################################################################################
 
@@ -30,28 +30,28 @@
     """
     This class defines the interface for invariant Plugin class
-    that can be used by the gui_manager.       
+    that can be used by the gui_manager.
     """
-    
+
     def __init__(self, standalone=False):
         PluginBase.__init__(self, name="Invariant", standalone=standalone)
-        
-        #dictionary containing data name and error on dy of that data 
+
+        # dictionary containing data name and error on dy of that data
         self.err_dy = {}
-       
-        #default state objects
-        self.state_reader = None 
+
+        # default state objects
+        self.state_reader = None
         self._extensions = '.inv'
-        self.temp_state = None 
-        self.__data = None 
-       
+        self.temp_state = None
+        self.__data = None
+
         # Log startup
         logging.info("Invariant plug-in started")
-       
+
     def help(self, evt):
         """
-        Show a general help dialog. 
+        Show a general help dialog.
         """
         from help_panel import  HelpWindow
-        frame = HelpWindow(None, -1) 
+        frame = HelpWindow(None, -1)
         if hasattr(frame, "IsIconized"):
             if not frame.IsIconized():
@@ -60,61 +60,61 @@
                     frame.SetIcon(icon)
                 except:
-                    pass  
+                    logging.error(sys.exc_value)
         frame.Show(True)
-        
+
     def get_data(self):
         """
         """
         return self.__data
-    
+
     def get_panels(self, parent):
         """
         Create and return the list of wx.Panels for your plug-in.
         Define the plug-in perspective.
-        
+
         Panels should inherit from DefaultPanel defined below,
         or should present the same interface. They must define
         "window_caption" and "window_name".
-        
+
         :param parent: parent window
-        
+
         :return: list of panels
         """
-        ## Save a reference to the parent
+        # # Save a reference to the parent
         self.parent = parent
-        self.frame = MDIFrame(self.parent, None, 'None', (100, 200))     
-        self.invariant_panel = InvariantPanel(parent=self.frame)        
+        self.frame = MDIFrame(self.parent, None, 'None', (100, 200))
+        self.invariant_panel = InvariantPanel(parent=self.frame)
         self.frame.set_panel(self.invariant_panel)
         self._frame_set_helper()
         self.invariant_panel.set_manager(manager=self)
-        self.perspective.append(self.invariant_panel.window_name)  
-        #Create reader when fitting panel are created
-        self.state_reader = reader(self.set_state)   
-        #append that reader to list of available reader 
+        self.perspective.append(self.invariant_panel.window_name)
+        # Create reader when fitting panel are created
+        self.state_reader = reader(self.set_state)
+        # append that reader to list of available reader
         loader = Loader()
         loader.associate_file_reader(".inv", self.state_reader)
-        #loader.associate_file_reader(".svs", self.state_reader)
+        # loader.associate_file_reader(".svs", self.state_reader)
         # Return the list of panels
         return [self.invariant_panel]
-  
+
     def get_context_menu(self, plotpanel=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 
+
+        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.  
-        
+        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 
+        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
         """
@@ -123,16 +123,15 @@
         invariant_hint = "Will displays the invariant panel for"
         invariant_hint += " further computation"
-        
+
         if graph.selected_plottable not in plotpanel.plots:
             return []
         data = plotpanel.plots[graph.selected_plottable]
-        
+
         if issubclass(data.__class__, Data1D):
-           if data.name != "$I_{obs}(q)$" and  data.name != " $P_{fit}(r)$":
-               return [[invariant_option, invariant_hint, 
-                                        self._compute_invariant]]
+            if data.name != "$I_{obs}(q)$" and  data.name != " $P_{fit}(r)$":
+                return [[invariant_option, invariant_hint, self._compute_invariant]]
         return []
 
-    def _compute_invariant(self, event):    
+    def _compute_invariant(self, event):
         """
         Open the invariant panel to invariant computation
@@ -147,7 +146,7 @@
             name = data.__class__.__name__
             msg = "Invariant use only Data1D got: [%s] " % str(name)
-            raise ValueError, msg 
+            raise ValueError, msg
         self.compute_helper(data=data)
-                
+
     def set_data(self, data_list=None):
         """
@@ -172,5 +171,5 @@
                         else:
                             error_msg += " %s  type %s \n" % (str(data.name),
-                                             str(data.__class__.__name__))
+                                                              str(data.__class__.__name__))
                             data_2d_list.append(data)
                 if len(data_2d_list) > 0:
@@ -178,6 +177,5 @@
                     msg += error_msg
                 if len(data_1d_list) == 0:
-                    wx.PostEvent(self.parent, 
-                    StatusEvent(status=msg, info='error'))
+                    wx.PostEvent(self.parent, StatusEvent(status=msg, info='error'))
                     return
                 msg += "Invariant panel does not allow multiple data!\n"
@@ -194,27 +192,23 @@
             if data is None:
                 msg += "invariant receives no data. \n"
-                wx.PostEvent(self.parent, 
-                     StatusEvent(status=msg, info='error'))
+                wx.PostEvent(self.parent, StatusEvent(status=msg, info='error'))
                 return
             if not issubclass(data.__class__, Data1D):
-                 msg += "invariant cannot be computed for data of "
-                 msg += "type %s\n" % (data.__class__.__name__)
-                 wx.PostEvent(self.parent, 
-                     StatusEvent(status=msg, info='error'))
-                 return
+                msg += "invariant cannot be computed for data of "
+                msg += "type %s\n" % (data.__class__.__name__)
+                wx.PostEvent(self.parent, StatusEvent(status=msg, info='error'))
+                return
             else:
-                wx.PostEvent(self.parent, NewPlotEvent(plot=data,
-                                           title=data.title))
+                wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=data.title))
                 try:
                     self.compute_helper(data)
                 except:
                     msg = "Invariant Set_data: " + str(sys.exc_value)
-                    wx.PostEvent(self.parent, StatusEvent(status=msg,
-                                                                info="error"))
-        else:    
+                    wx.PostEvent(self.parent, StatusEvent(status=msg, info="error"))
+        else:
             msg = "invariant cannot be computed for data of "
             msg += "type %s" % (data.__class__.__name__)
-            wx.PostEvent(self.parent, 
-                     StatusEvent(status=msg, info='error'))
+            wx.PostEvent(self.parent, StatusEvent(status=msg, info='error'))
+
     def delete_data(self, data_id):
         """
@@ -225,15 +219,15 @@
             if id == self.__data.id:
                 self.clear_panel()
-                
+
     def clear_panel(self):
         """
         """
         self.invariant_panel.clear_panel()
-        
+
     def compute_helper(self, data):
         """
         """
         if data is None:
-            return 
+            return
         # set current data if not it's a state data
         if not self.invariant_panel.is_state_data:
@@ -242,12 +236,12 @@
             # Set the data set to be user for invariant calculation
             self.invariant_panel.set_data(data=data)
-           
+
     def save_file(self, filepath, state=None):
         """
         Save data in provided state object.
-                
+
         :param filepath: path of file to write to
-        :param state: invariant state 
-        """     
+        :param state: invariant state
+        """
         # Write the state to file
         # First, check that the data is of the right type
@@ -258,12 +252,12 @@
         else:
             msg = "invariant.save_file: the data being saved is"
-            msg += " not a sas.dataloader.data_info.Data1D object" 
+            msg += " not a sas.dataloader.data_info.Data1D object"
             raise RuntimeError, msg
 
-    def set_state(self, state=None, datainfo=None):    
+    def set_state(self, state=None, datainfo=None):
         """
         Call-back method for the state reader.
         This method is called when a .inv/.svs file is loaded.
-        
+
         :param state: State object
         """
@@ -279,5 +273,5 @@
                 raise RuntimeError, msg
             # Make sure the user sees the invariant panel after loading
-            #self.parent.set_perspective(self.perspective)
+            # self.parent.set_perspective(self.perspective)
             self.on_perspective(event=None)
             name = data.meta_data['invstate'].file
@@ -286,13 +280,13 @@
             data.filename = name
 
-            data = self.parent.create_gui_data(data,None)
+            data = self.parent.create_gui_data(data, None)
             self.__data = data
             wx.PostEvent(self.parent, NewPlotEvent(plot=self.__data,
-                                        reset=True, title=self.__data.title))
+                                                   reset=True, title=self.__data.title))
             data_dict = {self.__data.id:self.__data}
             self.parent.add_data(data_list=data_dict)
             # set state
             self.invariant_panel.is_state_data = True
-            
+
             # Load the invariant states
             self.temp_state = state
@@ -300,41 +294,39 @@
             self.on_set_state_helper(None)
 
-        except: 
+        except:
             logging.error("invariant.set_state: %s" % sys.exc_value)
-            
+
     def on_set_state_helper(self, event=None):
         """
         Set the state when called by EVT_STATE_UPDATE event from guiframe
-        after a .inv/.svs file is loaded 
+        after a .inv/.svs file is loaded
         """
         self.invariant_panel.set_state(state=self.temp_state,
                                        data=self.__data)
         self.temp_state = None
-        
-        
+
+
     def plot_theory(self, data=None, name=None):
         """
         Receive a data set and post a NewPlotEvent to parent.
-        
+
         :param data: extrapolated data to be plotted
         :param name: Data's name to use for the legend
         """
-        #import copy
+        # import copy
         if data is None:
             id = str(self.__data.id) + name
             group_id = self.__data.group_id
-            wx.PostEvent(self.parent, NewPlotEvent(id=id,
-                                               group_id=group_id,
-                                               action='Remove'))
-            return
-    
+            wx.PostEvent(self.parent, NewPlotEvent(id=id, group_id=group_id, action='Remove'))
+            return
+
         new_plot = Data1D(x=[], y=[], dy=None)
         new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         scale = self.invariant_panel.get_scale()
         background = self.invariant_panel.get_background()
-        
+
         if scale != 0:
             # Put back the sacle and bkg for plotting
-            data.y = (data.y + background)/scale
+            data.y = (data.y + background) / scale
             new_plot = Data1D(x=data.x, y=data.y, dy=None)
             new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
@@ -342,7 +334,7 @@
             msg = "Scale can not be zero."
             raise ValueError, msg
-        if len(new_plot.x)== 0 :
-            return
-        
+        if len(new_plot.x) == 0:
+            return
+
         new_plot.name = name
         new_plot.xaxis(self.__data._xaxis, self.__data._xunit)
@@ -357,10 +349,10 @@
                 self.invariant_panel.state.theory_lowQ = copy.deepcopy(new_plot)
             elif name_head[0] == 'High':
-                self.invariant_panel.state.theory_highQ =copy.deepcopy(new_plot)
-            
+                self.invariant_panel.state.theory_highQ = copy.deepcopy(new_plot)
+
         self.parent.update_theory(data_id=self.__data.id, theory=new_plot)
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot,
                                                title=self.__data.title))
-        
+
     def plot_data(self, scale, background):
         """
@@ -370,11 +362,11 @@
         new_plot.name = self.__data.name
         new_plot.group_id = self.__data.group_id
-        new_plot.id = self.__data.id 
+        new_plot.id = self.__data.id
         new_plot.title = self.__data.title
-       
-        # Save data in a state: but seems to never happen 
+
+        # Save data in a state: but seems to never happen
         if new_plot != None:
             self.invariant_panel.state.data = copy.deepcopy(new_plot)
         wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot,
                                                title=new_plot.title))
-        
+
Index: src/sas/perspectives/invariant/invariant_details.py
===================================================================
--- src/sas/perspectives/invariant/invariant_details.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/invariant/invariant_details.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -8,13 +8,13 @@
 from invariant_widgets import OutputTextCtrl
 # Dimensions related to chart
-RECTANGLE_WIDTH  = 400.0  
+RECTANGLE_WIDTH = 400.0
 RECTANGLE_HEIGHT = 20
-#Invariant panel size 
+# Invariant panel size
 _BOX_WIDTH = 76
 
-#scale to use for a bar of value zero
-RECTANGLE_SCALE  = 0.0001
-DEFAULT_QSTAR = 1.0  
-  
+# scale to use for a bar of value zero
+RECTANGLE_SCALE = 0.0001
+DEFAULT_QSTAR = 1.0
+
 if sys.platform.count("win32") > 0:
     _STATICBOX_WIDTH = 450
@@ -27,34 +27,34 @@
     PANEL_HEIGHT = 430
     FONT_VARIANT = 1
-    
-ERROR_COLOR = wx.Colour(255,  0, 0, 128)
-EXTRAPOLATION_COLOR = wx.Colour(169,  169, 168, 128)
-INVARIANT_COLOR =  wx.Colour(67,  208,  128, 128)    
-  
-  
+
+ERROR_COLOR = wx.Colour(255, 0, 0, 128)
+EXTRAPOLATION_COLOR = wx.Colour(169, 169, 168, 128)
+INVARIANT_COLOR = wx.Colour(67, 208, 128, 128)
+
+
 class InvariantContainer(wx.Object):
     """
     This class stores some values resulting resulting from invariant
-    calculations. Given the value of total invariant, this class can also 
+    calculations. Given the value of total invariant, this class can also
     determine the percentage of invariants resulting from extrapolation.
     """
     def __init__(self):
-        #invariant at low range
+        # invariant at low range
         self.qstar_low = None
-        #invariant at low range error
+        # invariant at low range error
         self.qstar_low_err = None
-        #invariant 
+        # invariant
         self.qstar = None
-        #invariant error
+        # invariant error
         self.qstar_err = None
-        #invariant at high range
+        # invariant at high range
         self.qstar_high = None
-        #invariant at high range error
+        # invariant at high range error
         self.qstar_high_err = None
-        #invariant total
+        # invariant total
         self.qstar_total = None
-        #invariant error
+        # invariant error
         self.qstar_total_err = None
-        #scale
+        # scale
         self.qstar_low_percent = None
         self.qstar_high_percent = None
@@ -63,5 +63,5 @@
         self.existing_warning = False
         self.warning_msg = "No Details on calculations available...\n"
-        
+
     def compute_percentage(self):
         """
@@ -73,15 +73,15 @@
             self.qstar_high = None
             self.check_values()
-            return 
-        
-        #compute invariant percentage
+            return
+
+        # compute invariant percentage
         if self.qstar is None:
             self.qstar_percent = None
         else:
             try:
-                self.qstar_percent = float(self.qstar)/float(self.qstar_total)
+                self.qstar_percent = float(self.qstar) / float(self.qstar_total)
             except:
                 self.qstar_percent = 'error'
-        #compute low q invariant percentage
+        # compute low q invariant percentage
         if self.qstar_low is None:
             self.qstar_low_percent = None
@@ -89,8 +89,8 @@
             try:
                 self.qstar_low_percent = float(self.qstar_low)\
-                                            /float(self.qstar_total)
+                                            / float(self.qstar_total)
             except:
                 self.qstar_low_percent = 'error'
-        #compute high q invariant percentage
+        # compute high q invariant percentage
         if self.qstar_high is None:
             self.qstar_high_percent = None
@@ -98,9 +98,9 @@
             try:
                 self.qstar_high_percent = float(self.qstar_high)\
-                                                /float(self.qstar_total)
+                                                / float(self.qstar_total)
             except:
                 self.qstar_high_percent = 'error'
         wx.CallAfter(self.check_values)
-   
+
     def check_values(self):
         """
@@ -109,5 +109,5 @@
         if self.qstar_total is None and self.qstar is None:
             self.warning_msg = "Invariant not calculated.\n"
-            return 
+            return
         if self.qstar_total == 0:
             self.existing_warning = True
@@ -115,6 +115,6 @@
             self.warning_msg += "The calculations are likely "
             self.warning_msg += "to be unreliable!\n"
-            return 
-        #warning to the user when the extrapolated invariant is greater than %5
+            return
+        # warning to the user when the extrapolated invariant is greater than %5
         msg = ''
         if self.qstar_percent == 'error':
@@ -135,5 +135,5 @@
                 msg += "Error occurred when computing extrapolated invariant"
                 msg += " at low-Q region.\n"
-        elif self.qstar_low_percent is not None :
+        elif self.qstar_low_percent is not None:
             if self.qstar_low_percent >= 0.05:
                 self.existing_warning = True
@@ -172,76 +172,75 @@
             msg += "The sum of all extrapolated contributions is higher "
             msg += "than 5% of the invariant.\n"
-            
+
         if self.existing_warning:
             self.warning_msg = ''
-            self.warning_msg += msg 
+            self.warning_msg += msg
             self.warning_msg += "The calculations are likely to be"
             self.warning_msg += " unreliable!\n"
         else:
             self.warning_msg = "No Details on calculations available...\n"
-            
+
 class InvariantDetailsPanel(wx.Dialog):
     """
-    This panel describes proportion of invariants 
+    This panel describes proportion of invariants
     """
-    def __init__(self, parent=None, id=-1, qstar_container=None, 
-                                    title="Invariant Details",
-                                    size=(PANEL_WIDTH, PANEL_HEIGHT)):
+    def __init__(self, parent=None, id=-1, qstar_container=None,
+                 title="Invariant Details",
+                 size=(PANEL_WIDTH, PANEL_HEIGHT)):
         wx.Dialog.__init__(self, parent=parent, id=id, title=title, size=size)
-        
-        #Font size 
+
+        # Font size
         self.SetWindowVariant(variant=FONT_VARIANT)
         self.parent = parent
-        #self.qstar_container
+        # self.qstar_container
         self.qstar_container = qstar_container
-        #warning message
+        # warning message
         self.warning_msg = self.qstar_container.warning_msg
-   
-        #Define scale of each bar
+
+        # Define scale of each bar
         self.low_inv_percent = self.qstar_container.qstar_low_percent
         self.low_scale = self.get_scale(percentage=self.low_inv_percent,
-                                         scale_name="Extrapolated at Low Q")
+                                        scale_name="Extrapolated at Low Q")
         self.inv_percent = self.qstar_container.qstar_percent
-        self.inv_scale = self.get_scale(percentage=self.inv_percent, 
-                                            scale_name="Inv in Q range")
+        self.inv_scale = self.get_scale(percentage=self.inv_percent,
+                                        scale_name="Inv in Q range")
         self.high_inv_percent = self.qstar_container.qstar_high_percent
         self.high_scale = self.get_scale(percentage=self.high_inv_percent,
                                          scale_name="Extrapolated at High Q")
-       
-        #Default color the extrapolation bar is grey
+
+        # Default color the extrapolation bar is grey
         self.extrapolation_color_low = EXTRAPOLATION_COLOR
         self.extrapolation_color_high = EXTRAPOLATION_COLOR
         self.invariant_color = INVARIANT_COLOR
-        #change color of high and low bar when necessary
+        # change color of high and low bar when necessary
         self.set_color_bar()
-        #draw the panel itself
+        # draw the panel itself
         self._do_layout()
         self.set_values()
-  
+
     def _define_structure(self):
         """
         Define main sizers needed for this panel
         """
-        #Box sizers must be defined first before defining buttons/textctrls
+        # Box sizers must be defined first before defining buttons/textctrls
         # (MAC).
         self.main_sizer = wx.BoxSizer(wx.VERTICAL)
-        #Sizer related to chart
+        # Sizer related to chart
         chart_box = wx.StaticBox(self, -1, "Invariant Chart")
         self.chart_sizer = wx.StaticBoxSizer(chart_box, wx.VERTICAL)
         self.chart_sizer.SetMinSize((PANEL_WIDTH - 50, 110))
-        #Sizer related to invariant values
-        self.invariant_sizer =  wx.GridBagSizer(4, 4)
+        # Sizer related to invariant values
+        self.invariant_sizer = wx.GridBagSizer(4, 4)
         invariant_box = wx.StaticBox(self, -1, "Numerical Values")
-        self.invariant_box_sizer = wx.StaticBoxSizer(invariant_box,
-                                                      wx.HORIZONTAL)
+        self.invariant_box_sizer = wx.StaticBoxSizer(invariant_box, wx.HORIZONTAL)
 
         self.invariant_box_sizer.SetMinSize((PANEL_WIDTH - 50, -1))
-        #Sizer related to warning message
+        # Sizer related to warning message
         warning_box = wx.StaticBox(self, -1, "Warning")
         self.warning_sizer = wx.StaticBoxSizer(warning_box, wx.VERTICAL)
-        self.warning_sizer.SetMinSize((PANEL_WIDTH-50, -1))
-        #Sizer related to button
+        self.warning_sizer.SetMinSize((PANEL_WIDTH - 50, -1))
+        # Sizer related to button
         self.button_sizer = wx.BoxSizer(wx.HORIZONTAL)
-      
+
     def _layout_shart(self):
         """
@@ -250,13 +249,13 @@
         self.panel_chart = wx.Panel(self)
         self.panel_chart.Bind(wx.EVT_PAINT, self.on_paint)
-        self.chart_sizer.Add(self.panel_chart, 1, wx.EXPAND|wx.ALL, 0)
-        
+        self.chart_sizer.Add(self.panel_chart, 1, wx.EXPAND | wx.ALL, 0)
+
     def _layout_invariant(self):
         """
         Draw widgets related to invariant
         """
-        uncertainty = "+/-" 
+        uncertainty = "+/-"
         unit_invariant = '[1/(cm * A^3)]'
-     
+
         invariant_txt = wx.StaticText(self, -1, 'Q* from Data ')
         invariant_txt.SetToolTipString("Invariant in the data set's Q range.")
@@ -270,5 +269,5 @@
         hint_msg = "Unit of the invariant from data's Q range"
         invariant_units_txt.SetToolTipString(hint_msg)
-       
+
         invariant_low_txt = wx.StaticText(self, -1, 'Q* from Low-Q')
         hint_msg = "Extrapolated invariant from low-Q range."
@@ -284,5 +283,5 @@
         hint_msg = "Unit of the extrapolated invariant from  low-Q range"
         invariant_low_units_txt.SetToolTipString(hint_msg)
-        
+
         invariant_high_txt = wx.StaticText(self, -1, 'Q* from High-Q')
         hint_msg = "Extrapolated invariant from  high-Q range"
@@ -299,81 +298,80 @@
         hint_msg = "Unit of the extrapolated invariant from  high-Q range"
         invariant_high_units_txt.SetToolTipString(hint_msg)
-   
-        #Invariant low
+
+        # Invariant low
         iy = 0
-        ix = 0 
+        ix = 0
         self.invariant_sizer.Add(invariant_low_txt, (iy, ix), (1, 1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
         self.invariant_sizer.Add(self.invariant_low_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix += 1
-        self.invariant_sizer.Add( wx.StaticText(self, -1, uncertainty),
-                         (iy, ix), (1, 1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.invariant_sizer.Add(wx.StaticText(self, -1, uncertainty),
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         self.invariant_sizer.Add(self.invariant_low_err_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        ix += 1
-        self.invariant_sizer.Add(invariant_low_units_txt
-                         ,(iy, ix), (1, 1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
-        #Invariant 
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.invariant_sizer.Add(invariant_low_units_txt,
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        # Invariant
         iy += 1
-        ix = 0 
+        ix = 0
         self.invariant_sizer.Add(invariant_txt, (iy, ix), (1, 1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
         self.invariant_sizer.Add(self.invariant_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         self.invariant_sizer.Add(wx.StaticText(self, -1, uncertainty),
-                         (iy, ix), (1, 1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         self.invariant_sizer.Add(self.invariant_err_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix +=1
-        self.invariant_sizer.Add(invariant_units_txt
-                         ,(iy, ix), (1, 1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
-        #Invariant high
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.invariant_sizer.Add(invariant_units_txt,
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        # Invariant high
         iy += 1
-        ix = 0 
+        ix = 0
         self.invariant_sizer.Add(invariant_high_txt, (iy, ix), (1, 1),
-                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
         self.invariant_sizer.Add(self.invariant_high_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         self.invariant_sizer.Add(wx.StaticText(self, -1, uncertainty),
-                         (iy, ix), (1, 1),wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 1
         self.invariant_sizer.Add(self.invariant_high_err_tcl, (iy, ix), (1, 1),
-                            wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
-        ix += 1
-        self.invariant_sizer.Add(invariant_high_units_txt
-                         ,(iy, ix), (1, 1),wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        self.invariant_box_sizer.Add(self.invariant_sizer, 0,
-                                     wx.TOP|wx.BOTTOM, 10)  
-       
+                                 wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        ix += 1
+        self.invariant_sizer.Add(invariant_high_units_txt,
+                                 (iy, ix), (1, 1), wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        self.invariant_box_sizer.Add(self.invariant_sizer, 0, wx.TOP | wx.BOTTOM, 10)
+
     def _layout_warning(self):
         """
         Draw widgets related to warning
         """
-        #Warning [string]
-        self.warning_msg_txt = wx.StaticText(self, -1, self.warning_msg)  
+        # Warning [string]
+        self.warning_msg_txt = wx.StaticText(self, -1, self.warning_msg)
         if self.qstar_container.existing_warning:
-            self.warning_msg_txt.SetForegroundColour('red') 
+            self.warning_msg_txt.SetForegroundColour('red')
         self.warning_sizer.AddMany([(self.warning_msg_txt, 0,
-                                     wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)])
-        
+                                     wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10)])
+
     def _layout_button(self):
         """
         Draw widgets related to button
         """
-        #Close button
+        # Close button
         id = wx.NewId()
         button_ok = wx.Button(self, id, "Ok")
         button_ok.SetToolTipString("Give Details on Computation")
         self.Bind(wx.EVT_BUTTON, self.on_close, id=id)
-        self.button_sizer.AddMany([((20, 20), 0 , wx.LEFT, 350),
-                                   (button_ok, 0 , wx.RIGHT, 10)])
+        self.button_sizer.AddMany([((20, 20), 0, wx.LEFT, 350),
+                                   (button_ok, 0, wx.RIGHT, 10)])
     def _do_layout(self):
         """
@@ -386,10 +384,10 @@
         self._layout_button()
         self.main_sizer.AddMany([(self.chart_sizer, 0, wx.ALL, 10),
-                                 ( self.invariant_box_sizer, 0, wx.ALL, 10),
-                                  (self.warning_sizer, 0, wx.ALL, 10),
-                                  (self.button_sizer, 0, wx.ALL, 10)])
+                                 (self.invariant_box_sizer, 0, wx.ALL, 10),
+                                 (self.warning_sizer, 0, wx.ALL, 10),
+                                 (self.button_sizer, 0, wx.ALL, 10)])
         self.SetSizer(self.main_sizer)
-       
-        
+
+
     def set_values(self):
         """
@@ -399,23 +397,23 @@
         self.invariant_tcl.SetValue(value)
         value = format_number(self.qstar_container.qstar_err)
-        self.invariant_err_tcl.SetValue(value) 
+        self.invariant_err_tcl.SetValue(value)
         value = format_number(self.qstar_container.qstar_low)
         self.invariant_low_tcl.SetValue(value)
         value = format_number(self.qstar_container.qstar_low_err)
-        self.invariant_low_err_tcl.SetValue(value) 
+        self.invariant_low_err_tcl.SetValue(value)
         value = format_number(self.qstar_container.qstar_high)
         self.invariant_high_tcl.SetValue(value)
         value = format_number(self.qstar_container.qstar_high_err)
-        self.invariant_high_err_tcl.SetValue(value) 
+        self.invariant_high_err_tcl.SetValue(value)
 
     def get_scale(self, percentage, scale_name='scale'):
         """
-        Check scale receive in this panel. 
+        Check scale receive in this panel.
         """
         scale = RECTANGLE_SCALE
-        try: 
+        try:
             if percentage in [None, 0.0, "error"]:
-                 scale = RECTANGLE_SCALE
-                 return scale
+                scale = RECTANGLE_SCALE
+                return scale
             elif percentage < 0:
                 scale = RECTANGLE_SCALE
@@ -427,5 +425,5 @@
             self.warning_msg += "check this value : %s\n" % str(percentage)
         return  scale
-    
+
     def set_color_bar(self):
         """
@@ -435,12 +433,12 @@
         self.extrapolation_color_high = EXTRAPOLATION_COLOR
         self.invariant_color = INVARIANT_COLOR
-        #warning to the user when the extrapolated invariant is greater than %5
+        # warning to the user when the extrapolated invariant is greater than %5
         if self.low_scale >= 0.05 or self.low_scale > 1 or self.low_scale < 0:
-            self.extrapolation_color_low = ERROR_COLOR 
+            self.extrapolation_color_low = ERROR_COLOR
         if self.high_scale >= 0.05 or self.high_scale > 1 or self.high_scale < 0:
-            self.extrapolation_color_high = ERROR_COLOR 
+            self.extrapolation_color_high = ERROR_COLOR
         if self.inv_scale > 1 or self.inv_scale < 0:
-            self.invariant_color = ERROR_COLOR  
-    
+            self.invariant_color = ERROR_COLOR
+
     def on_close(self, event):
         """
@@ -448,5 +446,5 @@
         """
         self.Close()
-     
+
     def on_paint(self, event):
         """
@@ -461,5 +459,5 @@
             dc.DrawText(msg, 25, 25)
             return
-        #Start the drawing
+        # Start the drawing
         font = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT)
         font.SetWeight(wx.BOLD)
@@ -467,18 +465,18 @@
         # Draw a rectangle
         path = gc.CreatePath()
-        path.AddRectangle(-RECTANGLE_WIDTH/2,-RECTANGLE_HEIGHT/2,
-                          RECTANGLE_WIDTH/2,RECTANGLE_HEIGHT/2)
+        path.AddRectangle(-RECTANGLE_WIDTH / 2, -RECTANGLE_HEIGHT / 2,
+                          RECTANGLE_WIDTH / 2, RECTANGLE_HEIGHT / 2)
         x_origine = 20
         y_origine = 15
-        #Draw low rectangle
-        gc.PushState()        
+        # Draw low rectangle
+        gc.PushState()
         label = "Q* from Low-Q "
         PathFunc = gc.DrawPath
         w, h = gc.GetTextExtent(label)
         gc.DrawText(label, x_origine, y_origine)
-        #Translate the rectangle
-        x_center = x_origine + RECTANGLE_WIDTH * self.low_scale/2 + w +10
+        # Translate the rectangle
+        x_center = x_origine + RECTANGLE_WIDTH * self.low_scale / 2 + w + 10
         y_center = y_origine + h
-        gc.Translate(x_center, y_center)    
+        gc.Translate(x_center, y_center)
         gc.SetPen(wx.Pen("black", 1))
         gc.SetBrush(wx.Brush(self.extrapolation_color_low))
@@ -488,22 +486,22 @@
             low_percent = 'Error'
         else:
-            low_percent = format_number(self.low_inv_percent*100)+ '%'
+            low_percent = format_number(self.low_inv_percent * 100) + '%'
         x_center = 20
         y_center = -h
         gc.DrawText(low_percent, x_center, y_center)
         # Increase width by self.low_scale
-        gc.Scale(self.low_scale, 1.0) 
+        gc.Scale(self.low_scale, 1.0)
         PathFunc(path)
-        gc.PopState()  
-        #Draw rectangle for invariant   
-        gc.PushState()    # save it again
-        y_origine += 20         
+        gc.PopState()
+        # Draw rectangle for invariant
+        gc.PushState()  # save it again
+        y_origine += 20
         gc.DrawText("Q* from Data ", x_origine, y_origine)
         # offset to the lower part of the window
-        x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale/2 + w + 10
+        x_center = x_origine + RECTANGLE_WIDTH * self.inv_scale / 2 + w + 10
         y_center = y_origine + h
         gc.Translate(x_center, y_center)
         # 128 == half transparent
-        gc.SetBrush(wx.Brush(self.invariant_color)) 
+        gc.SetBrush(wx.Brush(self.invariant_color))
         # Increase width by self.inv_scale
         if self.inv_percent is None:
@@ -512,21 +510,21 @@
             inv_percent = 'Error'
         else:
-            inv_percent = format_number(self.inv_percent*100)+ '%'
-        x_center = 20 
+            inv_percent = format_number(self.inv_percent * 100) + '%'
+        x_center = 20
         y_center = -h
         gc.DrawText(inv_percent, x_center, y_center)
-        gc.Scale(self.inv_scale, 1.0)    
+        gc.Scale(self.inv_scale, 1.0)
         gc.DrawPath(path)
         gc.PopState()
         # restore saved state
-        #Draw rectangle for high invariant
-        gc.PushState() 
-        y_origine += 20 
-        gc.DrawText("Q* from High-Q ", x_origine, y_origine) 
-        #define the position of the new rectangle
-        x_center = x_origine + RECTANGLE_WIDTH * self.high_scale/2 + w + 10
+        # Draw rectangle for high invariant
+        gc.PushState()
+        y_origine += 20
+        gc.DrawText("Q* from High-Q ", x_origine, y_origine)
+        # define the position of the new rectangle
+        x_center = x_origine + RECTANGLE_WIDTH * self.high_scale / 2 + w + 10
         y_center = y_origine + h
         gc.Translate(x_center, y_center)
-        gc.SetBrush(wx.Brush(self.extrapolation_color_high)) 
+        gc.SetBrush(wx.Brush(self.extrapolation_color_high))
         # increase scale by self.high_scale
         if self.high_inv_percent is None:
@@ -535,10 +533,10 @@
             high_percent = 'Error'
         else:
-            high_percent = format_number(self.high_inv_percent*100)+ '%'
+            high_percent = format_number(self.high_inv_percent * 100) + '%'
         x_center = 20
         y_center = -h
         gc.DrawText(high_percent, x_center, y_center)
-       
-        gc.Scale(self.high_scale, 1.0)  
+
+        gc.Scale(self.high_scale, 1.0)
         gc.DrawPath(path)
         gc.PopState()
Index: src/sas/perspectives/invariant/invariant_state.py
===================================================================
--- src/sas/perspectives/invariant/invariant_state.py	(revision b9a5f0eb8e8cbff8f8d934bbfa4ea18168141e13)
+++ src/sas/perspectives/invariant/invariant_state.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -1,6 +1,7 @@
 """
+    State class for the invariant UI
 """
 
-#import time
+# import time
 import os
 import sys
@@ -8,5 +9,5 @@
 import copy
 import sas.dataloader
-#from xml.dom.minidom import parse
+# from xml.dom.minidom import parse
 from lxml import etree
 from sas.dataloader.readers.cansas_reader import Reader as CansasReader
@@ -20,60 +21,60 @@
 
 # default state
-list = {'file': 'None',
-        'compute_num':0,
-        'state_num':0,
-        'is_time_machine':False,
-        'background_tcl':0.0,
-        'scale_tcl':1.0,
-        'contrast_tcl':1.0,
-        'porod_constant_tcl':'',
-        'npts_low_tcl':10,
-        'npts_high_tcl':10,
-        'power_high_tcl':4.0,
-        'power_low_tcl': 4.0,
-        'enable_high_cbox':False,
-        'enable_low_cbox':False,
-        'guinier': True,
-        'power_law_high': False,
-        'power_law_low': False,
-        'fit_enable_high': False,
-        'fit_enable_low': False,
-        'fix_enable_high':True,
-        'fix_enable_low':True,
-        'volume_tcl':'',
-        'volume_err_tcl':'',
-        'surface_tcl':'',
-        'surface_err_tcl':''}
-# list of states: This list will be filled as panel 
+DEFAULT_STATE = {'file': 'None',
+                 'compute_num':0,
+                 'state_num':0,
+                 'is_time_machine':False,
+                 'background_tcl':0.0,
+                 'scale_tcl':1.0,
+                 'contrast_tcl':1.0,
+                 'porod_constant_tcl':'',
+                 'npts_low_tcl':10,
+                 'npts_high_tcl':10,
+                 'power_high_tcl':4.0,
+                 'power_low_tcl': 4.0,
+                 'enable_high_cbox':False,
+                 'enable_low_cbox':False,
+                 'guinier': True,
+                 'power_law_high': False,
+                 'power_law_low': False,
+                 'fit_enable_high': False,
+                 'fit_enable_low': False,
+                 'fix_enable_high':True,
+                 'fix_enable_low':True,
+                 'volume_tcl':'',
+                 'volume_err_tcl':'',
+                 'surface_tcl':'',
+                 'surface_err_tcl':''}
+# list of states: This list will be filled as panel
 # init and the number of states increases
 state_list = {}
 bookmark_list = {}
-# list of input parameters (will be filled up on panel init) used by __str__ 
+# list of input parameters (will be filled up on panel init) used by __str__
 input_list = {'background_tcl':0,
-        'scale_tcl':0,
-        'contrast_tcl':0,
-        'porod_constant_tcl':'',
-        'npts_low_tcl':0,
-        'npts_high_tcl':0,
-        'power_high_tcl':0,
-        'power_low_tcl': 0}  
-# list of output parameters (order sensitive) used by __str__    
-output_list = [["qstar_low",      "Q* from low Q extrapolation [1/(cm*A)]"],
-               ["qstar_low_err",             "dQ* from low Q extrapolation"],
-               ["qstar_low_percent",  "Q* percent from low Q extrapolation"],
-               ["qstar",              "Q* from data [1/(cm*A)]"],
-               ["qstar_err",                                "dQ* from data"],
-               ["qstar_percent",                     "Q* percent from data"],
-               ["qstar_high",    "Q* from high Q extrapolation [1/(cm*A)]"],
-               ["qstar_high_err",           "dQ* from high Q extrapolation"],
+              'scale_tcl':0,
+              'contrast_tcl':0,
+              'porod_constant_tcl':'',
+              'npts_low_tcl':0,
+              'npts_high_tcl':0,
+              'power_high_tcl':0,
+              'power_low_tcl': 0}
+# list of output parameters (order sensitive) used by __str__
+output_list = [["qstar_low", "Q* from low Q extrapolation [1/(cm*A)]"],
+               ["qstar_low_err", "dQ* from low Q extrapolation"],
+               ["qstar_low_percent", "Q* percent from low Q extrapolation"],
+               ["qstar", "Q* from data [1/(cm*A)]"],
+               ["qstar_err", "dQ* from data"],
+               ["qstar_percent", "Q* percent from data"],
+               ["qstar_high", "Q* from high Q extrapolation [1/(cm*A)]"],
+               ["qstar_high_err", "dQ* from high Q extrapolation"],
                ["qstar_high_percent", "Q* percent from low Q extrapolation"],
-               ["qstar_total",         "total Q* [1/(cm*A)]"],
-               ["qstar_total_err",                              "total dQ*"],
-               ["volume",                                 "volume fraction"],
-               ["volume_err",                       "volume fraction error"],
-               ["surface",                               "specific surface"],
-               ["surface_err",                     "specific surface error"]]
-
-   
+               ["qstar_total", "total Q* [1/(cm*A)]"],
+               ["qstar_total_err", "total dQ*"],
+               ["volume", "volume fraction"],
+               ["volume_err", "volume fraction error"],
+               ["surface", "specific surface"],
+               ["surface_err", "specific surface error"]]
+
+
 
 class InvariantState(object):
@@ -85,38 +86,38 @@
         Default values
         """
-        # Input 
-        self.file  = None
+        # Input
+        self.file = None
         self.data = Data1D(x=[], y=[], dx=None, dy=None)
-        self.theory_lowQ =  Data1D(x=[], y=[], dy=None)
+        self.theory_lowQ = Data1D(x=[], y=[], dy=None)
         self.theory_lowQ.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
         self.theory_highQ = Data1D(x=[], y=[], dy=None)
         self.theory_highQ.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
-        #self.is_time_machine = False
-        self.saved_state = list
+        # self.is_time_machine = False
+        self.saved_state = DEFAULT_STATE
         self.state_list = state_list
         self.bookmark_list = bookmark_list
         self.input_list = input_list
         self.output_list = output_list
-        
+
         self.compute_num = 0
         self.state_num = 0
         self.timestamp = ('00:00:00', '00/00/0000')
         self.container = None
-        #plot image
+        # plot image
         self.wximbmp = None
         # report_html strings
         import sas.perspectives.invariant as invariant
         path = invariant.get_data_path(media='media')
-        path_report_html = os.path.join(path,"report_template.html")
-        html_template = open(path_report_html,"r")
+        path_report_html = os.path.join(path, "report_template.html")
+        html_template = open(path_report_html, "r")
         self.template_str = html_template.read()
         self.report_str = self.template_str
-        #self.report_str_save = None
+        # self.report_str_save = None
         html_template.close()
-        
+
     def __str__(self):
         """
         Pretty print
-            
+
         : return: string representing the state
         """
@@ -132,12 +133,12 @@
         state += "State No.: %d \n" % state_num
         state += "\n=== Inputs ===\n"
-        
+
         # text ctl general inputs ( excluding extrapolation text ctl)
-        for key, value in self.input_list.iteritems(): 
+        for key, value in self.input_list.iteritems():
             if value == '':
                 continue
-            key_split = key.split('_') 
-            max_ind = len(key_split)-1
-            if key_split[max_ind] == 'tcl': 
+            key_split = key.split('_')
+            max_ind = len(key_split) - 1
+            if key_split[max_ind] == 'tcl':
                 name = ""
                 if key_split[1] == 'low' or key_split[1] == 'high':
@@ -146,6 +147,6 @@
                     name += " %s" % key_split[ind]
                 state += "%s:   %s\n" % (name.lstrip(" "), value)
-                
-        # other input parameters       
+
+        # other input parameters
         extra_lo = compute_state['enable_low_cbox']
         if compute_state['enable_low_cbox']:
@@ -157,34 +158,34 @@
         if compute_state['enable_high_cbox']:
             extra_hi = 'Power law'
-        state += "\nExtrapolation:  High=%s; Low=%s\n" %(extra_hi, extra_lo)   
+        state += "\nExtrapolation:  High=%s; Low=%s\n" % (extra_hi, extra_lo)
         low_off = False
         high_off = False
-        for key, value in self.input_list.iteritems(): 
-            key_split = key.split('_') 
-            max_ind = len(key_split) - 1   
-            if key_split[max_ind] == 'tcl': 
-                name = "" 
+        for key, value in self.input_list.iteritems():
+            key_split = key.split('_')
+            max_ind = len(key_split) - 1
+            if key_split[max_ind] == 'tcl':
+                name = ""
                 # check each buttons whether or not ON or OFF
                 if key_split[1] == 'low' or key_split[1] == 'high':
                     if not compute_state['enable_low_cbox'] and \
-                        key_split[max_ind-1] == 'low':
+                        key_split[max_ind - 1] == 'low':
                         low_off = True
-                        continue              
+                        continue
                     elif not compute_state['enable_high_cbox'] and \
-                        key_split[max_ind-1] == 'high':
+                        key_split[max_ind - 1] == 'high':
                         high_off = True
                         continue
                     elif extra_lo == 'Guinier' and key_split[0] == 'power' and \
-                        key_split[max_ind-1] == 'low':
+                        key_split[max_ind - 1] == 'low':
                         continue
                     for ind in range(0, max_ind):
                         name += " %s" % key_split[ind]
                     name = name.lstrip(" ")
-                    if name == "power low" :
+                    if name == "power low":
                         if compute_state['fix_enable_low']:
                             name += ' (Fixed)'
                         else:
                             name += ' (Fitted)'
-                    if name == "power high" :
+                    if name == "power high":
                         if compute_state['fix_enable_high']:
                             name += ' (Fixed)'
@@ -195,5 +196,5 @@
         state += "\n=== Outputs ==="
         for item in output_list:
-            item_split = item[0].split('_') 
+            item_split = item[0].split('_')
             # Exclude the extrapolation that turned off
             if len(item_split) > 1:
@@ -204,16 +205,16 @@
             max_ind = len(item_split) - 1
             value = None
-            try:
+            if hasattr(self.container, item[0]):
                 # Q* outputs
-                exec "value = self.container.%s\n" % item[0]
-            except:
+                value = getattr(self.container, item[0])
+            else:
                 # other outputs than Q*
                 name = item[0] + "_tcl"
                 if name in self.saved_state.keys():
-                    exec "value = self.saved_state['%s']" % name
-                
-            # Exclude the outputs w/''    
+                    value = self.saved_state[name]
+
+            # Exclude the outputs w/''
             if value == '':
-                continue    
+                continue
             # Error outputs
             if item_split[max_ind] == 'err':
@@ -221,13 +222,10 @@
             # Percentage outputs
             elif item_split[max_ind] == 'percent':
-                try:
-                    value = float(value) * 100
-                except:
-                    pass
+                value = float(value) * 100
                 state += "(%s %s)" % (format_number(value), '%')
             # Outputs
             else:
-                state += "\n%s:   %s " % (item[1], 
-                                        format_number(value, high=True))
+                state += "\n%s:   %s " % (item[1],
+                                          format_number(value, high=True))
         # Include warning msg
         if self.container is not None:
@@ -244,13 +242,13 @@
         """
         Writes the state of the InversionControl panel to file, as XML.
-        
+
         Compatible with standalone writing, or appending to an
         already existing XML document. In that case, the XML document
-        is required. An optional entry node in the XML document 
+        is required. An optional entry node in the XML document
         may also be given.
-        
+
         : param file: file to write to
         : param doc: XML document object [optional]
-        : param entry_node: XML node within the XML document at which we will append the data [optional]
+        : param entry_node: XML node within the document at which we will append the data [optional]
         """
         # TODO: Get this to work
@@ -261,7 +259,7 @@
         if doc is None:
             impl = getDOMImplementation()
-        
-            doc_type = impl.createDocumentType(INVNODE_NAME, "1.0", "1.0")     
-        
+
+            doc_type = impl.createDocumentType(INVNODE_NAME, "1.0", "1.0")
+
             newdoc = impl.createDocument(None, INVNODE_NAME, doc_type)
             top_element = newdoc.documentElement
@@ -274,9 +272,9 @@
             else:
                 entry_node.appendChild(top_element)
-                
+
         attr = newdoc.createAttribute("version")
         attr.nodeValue = '1.0'
         top_element.setAttributeNode(attr)
-        
+
         # File name
         element = newdoc.createElement("filename")
@@ -286,5 +284,5 @@
             element.appendChild(newdoc.createTextNode(str(file)))
         top_element.appendChild(element)
-        
+
         element = newdoc.createElement("timestamp")
         element.appendChild(newdoc.createTextNode(time.ctime(timestamp)))
@@ -293,36 +291,36 @@
         element.setAttributeNode(attr)
         top_element.appendChild(element)
-        
+
         # Current state
         state = newdoc.createElement("state")
         top_element.appendChild(state)
-        
-        for name,value in self.saved_state.iteritems():
+
+        for name, value in self.saved_state.iteritems():
             element = newdoc.createElement(str(name))
             element.appendChild(newdoc.createTextNode(str(value)))
             state.appendChild(element)
-              
+
         # State history list
         history = newdoc.createElement("history")
         top_element.appendChild(history)
-        
+
         for name, value in self.state_list.iteritems():
             history_element = newdoc.createElement('state_' + str(name))
-            for state_name,state_value in value.iteritems():
+            for state_name, state_value in value.iteritems():
                 state_element = newdoc.createElement(str(state_name))
                 child = newdoc.createTextNode(str(state_value))
                 state_element.appendChild(child)
                 history_element.appendChild(state_element)
-            #history_element.appendChild(state_list_element)
+            # history_element.appendChild(state_list_element)
             history.appendChild(history_element)
 
         # Bookmarks  bookmark_list[self.bookmark_num] = [\
-        #my_time,date,state,comp_state]
+        # my_time,date,state,comp_state]
         bookmark = newdoc.createElement("bookmark")
         top_element.appendChild(bookmark)
-        item_list = ['time','date','state','comp_state']
+        item_list = ['time', 'date', 'state', 'comp_state']
         for name, value_list in self.bookmark_list.iteritems():
-            element = newdoc.createElement('mark_'+ str(name))
-            _,date,state,comp_state = value_list
+            element = newdoc.createElement('mark_' + str(name))
+            _, date, state, comp_state = value_list
             time_element = newdoc.createElement('time')
             time_element.appendChild(newdoc.createTextNode(str(value_list[0])))
@@ -354,11 +352,11 @@
         else:
             return newdoc
-        
+
     def fromXML(self, file=None, node=None):
         """
         Load invariant states from a file
-            
+
         : param file: .inv file
-        : param node: node of a XML document to read from       
+        : param node: node of a XML document to read from
         """
         if file is not None:
@@ -366,5 +364,5 @@
             msg += " format for invariant files"
             raise RuntimeError, msg
-        
+
         if node.get('version')\
             and node.get('version') == '1.0':
@@ -384,5 +382,5 @@
                     msg += " timestamp\n %s" % sys.exc_value
                     logging.error(msg)
-            
+
             # Parse bookmarks
             entry_bookmark = get_content('ns:bookmark', node)
@@ -391,6 +389,6 @@
                 temp_state = {}
                 temp_bookmark = {}
-                entry = get_content('ns:mark_%s' % ind, entry_bookmark) 
-                                
+                entry = get_content('ns:mark_%s' % ind, entry_bookmark)
+
                 if entry is not None:
                     my_time = get_content('ns:time', entry)
@@ -399,27 +397,18 @@
                     val_date = str(date.text.strip())
                     state_entry = get_content('ns:state', entry)
-                    for item in list:
-
+                    for item in DEFAULT_STATE:
                         input_field = get_content('ns:%s' % item, state_entry)
                         val = str(input_field.text.strip())
                         if input_field is not None:
-                            try:
-                                exec "temp_state['%s'] = %s" % (item, val)      
-                            except:
-                                exec "temp_state['%s'] = '%s'" % (item, val)
+                            temp_state[item] = val
                     comp_entry = get_content('ns:comp_state', entry)
-                    
-                    for item in list:
+
+                    for item in DEFAULT_STATE:
                         input_field = get_content('ns:%s' % item, comp_entry)
                         val = str(input_field.text.strip())
                         if input_field is not None:
-                            try:
-                                exec "temp_bookmark['%s'] = %s" % (item, val)      
-                            except:
-                                exec "temp_bookmark['%s'] = '%s'" % (item, val)
+                            temp_bookmark[item] = val
                     try:
-                        cmd = "self.bookmark_list[%s] = [val_time,"
-                        cmd += "val_date,temp_state,temp_bookmark]"
-                        exec cmd % ind
+                        self.bookmark_list[ind] = [val_time, val_date, temp_state, temp_bookmark]
                     except:
                         raise "missing components of bookmarks..."
@@ -429,22 +418,18 @@
             for ind in range(0, len(entry_history)):
                 temp_state = {}
-                entry = get_content('ns:state_%s' % ind, entry_history) 
+                entry = get_content('ns:state_%s' % ind, entry_history)
 
                 if entry is not None:
-                    for item in list:
-                        input_field = get_content('ns:%s' % item, entry )
+                    for item in DEFAULT_STATE:
+                        input_field = get_content('ns:%s' % item, entry)
                         val = str(input_field.text.strip())
-
                         if input_field is not None:
-                            try:
-                                exec "temp_state['%s'] = %s" % (item, val)         
-                            except:
-                                exec "temp_state['%s'] = '%s'" % (item, val)
-                            finally:
-                                exec "self.state_list['%s'] = temp_state" % ind 
+                            temp_state[item] = val
+                            self.state_list[ind] = temp_state
+
             # Parse current state (ie, saved_state)
-            entry = get_content('ns:state', node)           
+            entry = get_content('ns:state', node)
             if entry is not None:
-                for item in list:
+                for item in DEFAULT_STATE:
                     input_field = get_content('ns:%s' % item, entry)
                     val = str(input_field.text.strip())
@@ -452,13 +437,13 @@
                         self.set_saved_state(name=item, value=val)
             self.file = file_name
-            
+
     def set_report_string(self):
         """
-        Get the values (strings) from __str__ for report 
+        Get the values (strings) from __str__ for report
         """
         strings = self.__str__()
-    
+
         # default string values
-        for num in range (1, 19):
+        for num in range(1, 19):
             exec "s_%s = 'NA'" % str(num)
         lines = strings.split('\n')
@@ -491,5 +476,5 @@
                     s_10 = item[1]
                 elif item[0] == "volume fraction":
-                    val=item[1].split("+-")[0].strip()
+                    val = item[1].split("+-")[0].strip()
                     error = item[1].split("+-")[1].strip()
                     s_17 = val + " &plusmn; " + error
@@ -499,9 +484,9 @@
                     s_18 = val + " &plusmn; " + error
                 elif item[0].split("(")[0].strip() == "power low":
-                    s_11 = item[0]+" ="+item[1]
+                    s_11 = item[0] + " =" + item[1]
                 elif item[0].split("(")[0].strip() == "power high":
-                    s_12 = item[0]+" ="+item[1]
+                    s_12 = item[0] + " =" + item[1]
                 elif item[0].split("[")[0].strip() == "Q* from low Q extrapolation":
-                    #looks messy but this way the symbols +_ and % work on html
+                    # looks messy but this way the symbols +_ and % work on html
                     val = item[1].split("+-")[0].strip()
                     error = item[1].split("+-")[1].strip()
@@ -532,10 +517,10 @@
 
         # make plot image
-        self.set_plot_state(extra_high=bool_0[1],extra_low=bool_1[1])
+        self.set_plot_state(extra_high=bool_0[1], extra_low=bool_1[1])
         # get ready for report with setting all the html strings
         self.report_str = str(self.template_str) % (s_1, s_2,
-                                        s_3, s_4, s_5, s_6, s_7, s_8,
-                                    s_9, s_10, s_11, s_12, s_13, s_14, s_15,
-                                        s_16, s_17, s_18, file_name, "%s")
+                                                    s_3, s_4, s_5, s_6, s_7, s_8,
+                                                    s_9, s_10, s_11, s_12, s_13, s_14, s_15,
+                                                    s_16, s_17, s_18, file_name, "%s")
 
     def _check_html_format(self, name):
@@ -545,38 +530,31 @@
         if name.count('%'):
             name = name.replace('%', '&#37')
-        
+
         return name
-        
+
     def set_saved_state(self, name, value):
         """
-        Set the state list 
-                    
+        Set the state list
+
         : param name: name of the state component
         : param value: value of the state component
         """
-        rb_list = [['power_law_low','guinier'],
-                   ['fit_enable_low','fix_enable_low'],
-                   ['fit_enable_high','fix_enable_high']]
-
-        try:
-            if value == None or value.lstrip().rstrip() == '':
-                exec "self.%s = '%s'" % (name, value)
-                exec "self.saved_state['%s'] = '%s'" % (name, value)
-            else:
-                exec 'self.%s = %s' % (name, value)
-                exec "self.saved_state['%s'] = %s" % (name, value)
-            # set the count part of radio button clicked 
-            # False for the saved_state
-            for title, content in rb_list:
-                if name ==  title:
-                    name = content 
-                    value = False     
-                elif name == content:
-                    name = title
-                    value = False 
-            exec "self.saved_state['%s'] = '%s'" % (name, value)     
-            self.state_num = self.saved_state['state_num']
-        except:           
-            pass
+        rb_list = [['power_law_low', 'guinier'],
+                   ['fit_enable_low', 'fix_enable_low'],
+                   ['fit_enable_high', 'fix_enable_high']]
+
+        self.name = value
+        self.saved_state[name] = value
+        # set the count part of radio button clicked
+        # False for the saved_state
+        for title, content in rb_list:
+            if name == title:
+                name = content
+                value = False
+            elif name == content:
+                name = title
+                value = False
+        self.saved_state[name] = value
+        self.state_num = self.saved_state['state_num']
 
     def set_plot_state(self, extra_high=False, extra_low=False):
@@ -584,5 +562,5 @@
         Build image state that wx.html understand
         by plotting, putting it into wx.FileSystem image object
-        
+
         : extrap_high,extra_low: low/high extrapolations
         are possible extra-plots
@@ -593,42 +571,42 @@
         from matplotlib.backends.backend_agg import FigureCanvasAgg
 
-        #we use simple plot, not plotpanel
-        #make matlab figure
+        # we use simple plot, not plotpanel
+        # make matlab figure
         fig = plt.figure()
         fig.set_facecolor('w')
         graph = fig.add_subplot(111)
 
-        #data plot
+        # data plot
         graph.errorbar(self.data.x, self.data.y, yerr=self.data.dy, fmt='o')
-        #low Q extrapolation fit plot
+        # low Q extrapolation fit plot
         if not extra_low == 'False':
-            graph.plot(self.theory_lowQ.x,self.theory_lowQ.y)
-        #high Q extrapolation fit plot
+            graph.plot(self.theory_lowQ.x, self.theory_lowQ.y)
+        # high Q extrapolation fit plot
         if not extra_high == 'False':
-            graph.plot(self.theory_highQ.x,self.theory_highQ.y)
+            graph.plot(self.theory_highQ.x, self.theory_highQ.y)
         graph.set_xscale("log", nonposx='clip')
         graph.set_yscale("log", nonposy='clip')
-        graph.set_xlabel('$\\rm{Q}(\\AA^{-1})$', fontsize = 12)
-        graph.set_ylabel('$\\rm{Intensity}(cm^{-1})$', fontsize = 12)
+        graph.set_xlabel('$\\rm{Q}(\\AA^{-1})$', fontsize=12)
+        graph.set_ylabel('$\\rm{Intensity}(cm^{-1})$', fontsize=12)
         canvas = FigureCanvasAgg(fig)
-        #actually make image
+        # actually make image
         canvas.draw()
-        
-        #make python.Image object 
-        #size
+
+        # make python.Image object
+        # size
         w, h = canvas.get_width_height()
-        #convert to wx.Image
-        wximg = wx.EmptyImage(w,h)
-        #wxim.SetData(img.convert('RGB').tostring() ) 
-        wximg.SetData(canvas.tostring_rgb()) 
-        #get the dynamic image for the htmlwindow
+        # convert to wx.Image
+        wximg = wx.EmptyImage(w, h)
+        # wxim.SetData(img.convert('RGB').tostring() )
+        wximg.SetData(canvas.tostring_rgb())
+        # get the dynamic image for the htmlwindow
         wximgbmp = wx.BitmapFromImage(wximg)
-        #store the image in wx.FileSystem Object 
+        # store the image in wx.FileSystem Object
         wx.FileSystem.AddHandler(wx.MemoryFSHandler())
         # use wx.MemoryFSHandler
         self.imgRAM = wx.MemoryFSHandler()
-        #AddFile, image can be retrieved with 'memory:filename'
+        # AddFile, image can be retrieved with 'memory:filename'
         self.imgRAM.AddFile('img_inv.png', wximgbmp, wx.BITMAP_TYPE_PNG)
-        
+
         self.wximgbmp = 'memory:img_inv.png'
         self.image = fig
@@ -638,32 +616,32 @@
     Class to load a .inv invariant file
     """
-    ## File type
+    # # File type
     type_name = "Invariant"
-    
-    ## Wildcards
+
+    # # Wildcards
     type = ["Invariant file (*.inv)|*.inv",
             "SASView file (*.svs)|*.svs"]
-    ## List of allowed extensions
-    ext = ['.inv', '.INV', '.svs', 'SVS']  
-    
+    # # List of allowed extensions
+    ext = ['.inv', '.INV', '.svs', 'SVS']
+
     def __init__(self, call_back, cansas=True):
         """
         Initialize the call-back method to be called
         after we load a file
-        
+
         : param call_back: call-back method
         : param cansas:  True = files will be written/read in CanSAS format
-                        False = write CanSAS format  
-        """
-        ## Call back method to be executed after a file is read
+                        False = write CanSAS format
+        """
+        # # Call back method to be executed after a file is read
         self.call_back = call_back
-        ## CanSAS format flag
+        # # CanSAS format flag
         self.cansas = cansas
         self.state = None
 
     def read(self, path):
-        """ 
+        """
         Load a new invariant state from file
-        
+
         : param path: file path
         : return: None
@@ -673,10 +651,10 @@
         else:
             return self._read_standalone(path)
-        
+
     def _read_standalone(self, path):
-        """ 
+        """
         Load a new invariant state from file.
         The invariant node is assumed to be the top element.
-        
+
         : param path: file path
         : return: None
@@ -686,14 +664,14 @@
 
         state.fromXML(file=path)
-        
+
         # Call back to post the new state
         self.call_back(state)
         return None
-    
+
     def _parse_state(self, entry):
         """
         Read an invariant result from an XML node
-        
-        : param entry: XML node to read from 
+
+        : param entry: XML node to read from
         : return: InvariantState object
         """
@@ -710,13 +688,13 @@
             msg = "XML document does not contain invariant"
             msg += " information.\n %s" % sys.exc_value
-            logging.info(msg)  
+            logging.info(msg)
         return state
-    
+
     def _read_cansas(self, path):
-        """ 
+        """
         Load data and invariant information from a CanSAS XML file.
-        
+
         : param path: file path
-        : return: Data1D object if a single SASentry was found, 
+        : return: Data1D object if a single SASentry was found,
                     or a list of Data1D objects if multiple entries were found,
                     or None of nothing was found
@@ -726,26 +704,26 @@
         output = []
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             root, extension = os.path.splitext(basename)
-            
+
             if  extension.lower() in self.ext or \
                 extension.lower() == '.xml':
                 tree = etree.parse(path, parser=etree.ETCompatXMLParser())
-       
+
                 # Check the format version number
-                # Specifying the namespace will take care of 
-                # the file format version 
+                # Specifying the namespace will take care of
+                # the file format version
                 root = tree.getroot()
-                
+
                 entry_list = root.xpath('/ns:SASroot/ns:SASentry',
                                         namespaces={'ns': CANSAS_NS})
-                
+
                 for entry in entry_list:
-                    
+
                     sas_entry, _ = self._parse_entry(entry)
                     invstate = self._parse_state(entry)
-                    
-                    #invstate could be None when .svs file is loaded
-                    #in this case, skip appending to output
+
+                    # invstate could be None when .svs file is loaded
+                    # in this case, skip appending to output
                     if invstate != None:
                         sas_entry.meta_data['invstate'] = invstate
@@ -762,16 +740,16 @@
             self.state = output[0].meta_data['invstate']
             self.call_back(state=output[0].meta_data['invstate'],
-                          datainfo = output[0])
+                           datainfo=output[0])
             return output[0]
         else:
-            return output                
-    
+            return output
+
     def get_state(self):
         return self.state
-    
+
     def write(self, filename, datainfo=None, invstate=None):
         """
         Write the content of a Data1D as a CanSAS XML file
-        
+
         : param filename: name of the file to write
         : param datainfo: Data1D object
@@ -780,5 +758,5 @@
         # Sanity check
         if self.cansas == True:
-            doc = self.write_toXML(datainfo,invstate)
+            doc = self.write_toXML(datainfo, invstate)
             # Write the XML document
             fd = open(filename, 'w')
@@ -787,21 +765,21 @@
         else:
             invstate.toXML(file=filename)
-        
+
     def write_toXML(self, datainfo=None, state=None):
         """
         Write toXML, a helper for write()
-        
+
         : return: xml doc
         """
         if datainfo is None:
-            datainfo = sas.dataloader.data_info.Data1D(x=[], y=[])    
+            datainfo = sas.dataloader.data_info.Data1D(x=[], y=[])
         elif not issubclass(datainfo.__class__, sas.dataloader.data_info.Data1D):
             msg = "The cansas writer expects a Data1D"
             msg += " instance: %s" % str(datainfo.__class__.__name__)
             raise RuntimeError, msg
-        #make sure title and data run is filled up.
+        # make sure title and data run is filled up.
         if datainfo.title == None or datainfo.title == '':
             datainfo.title = datainfo.name
-        if datainfo.run_name == None or datainfo.run_name == {}: 
+        if datainfo.run_name == None or datainfo.run_name == {}:
             datainfo.run = [str(datainfo.name)]
             datainfo.run_name[0] = datainfo.name
@@ -810,5 +788,5 @@
         # Add the invariant information to the XML document
         if state is not None:
-            doc = state.toXML(datainfo.name,doc=doc, entry_node=sasentry)
+            doc = state.toXML(datainfo.name, doc=doc, entry_node=sasentry)
         return doc
 
Index: src/sas/perspectives/invariant/invariant_widgets.py
===================================================================
--- src/sas/perspectives/invariant/invariant_widgets.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/invariant/invariant_widgets.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -1,15 +1,11 @@
-
-
-
 ################################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
 #
-#See the license text in license.txt
+# See the license text in license.txt
 #
-#copyright 2009, University of Tennessee
+# copyright 2009, University of Tennessee
 ################################################################################
-
 
 import wx
@@ -23,5 +19,5 @@
         ScrolledPanel.__init__(self, *args, **kwds)
         self.SetupScrolling()
-        
+
 class InvTextCtrl(wx.TextCtrl):
     """
@@ -31,8 +27,8 @@
     def __init__(self, *args, **kwds):
         wx.TextCtrl.__init__(self, *args, **kwds)
-        ## 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
         self.full_selection = False
-        ## Call back for EVT_SET_FOCUS events
+        # # Call back for EVT_SET_FOCUS events
         _on_set_focus_callback = None
 
@@ -40,39 +36,39 @@
         self.Bind(wx.EVT_LEFT_UP, self._highlight_text)
         self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
-        
+
     def _on_set_focus(self, event):
         """
         Catch when the text control is set in focus to highlight the whole
         text if necessary
-        
+
         :param event: mouse event
         """
         event.Skip()
         self.full_selection = True
-        
+
     def _highlight_text(self, event):
         """
         Highlight text of a TextCtrl only of no text has be selected
-        
+
         :param event: mouse event
         """
         # Make sure the mouse event is available to other listeners
         event.Skip()
-        control  = event.GetEventObject()
+        control = event.GetEventObject()
         if self.full_selection:
             self.full_selection = False
             # Check that we have a TextCtrl
             if issubclass(control.__class__, wx.TextCtrl):
-                # Check whether text has been selected, 
+                # Check whether text has been selected,
                 # if not, select the whole string
                 (start, end) = control.GetSelection()
                 if start == end:
                     control.SetSelection(-1, -1)
-           
+
 
 class OutputTextCtrl(wx.TextCtrl):
     """
     Text control used to display outputs.
-    No editing allowed. The background is 
+    No editing allowed. The background is
     grayed out. User can't select text.
     """
@@ -81,19 +77,19 @@
         self.SetEditable(False)
         self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
-        
+
         # Bind to mouse event to avoid text highlighting
         # The event will be skipped once the call-back
         # is called.
-        
+
         self.Bind(wx.EVT_MOUSE_EVENTS, self._click)
 
-        
+
     def _click(self, event):
         """
         Prevent further handling of the mouse event
         by not calling Skip().
-        """ 
+        """
         pass
-    
+
 class DataDialog(wx.Dialog):
     """
@@ -110,55 +106,54 @@
         self._choice_sizer = wx.GridBagSizer(5, 5)
         self._panel = DialogPanel(self, style=wx.RAISED_BORDER,
-                               size=(WIDTH-20, HEIGHT/3))
+                                  size=(WIDTH - 20, HEIGHT / 3))
         self.SetSizer(self._sizer_main)
         self.__do_layout(data_list, text=text)
         self.Layout()
-        
+
     def __do_layout(self, data_list, text=''):
         """
         layout the dialog
         """
-        #add text
+        # add text
         if text.strip() == "":
             text = "This Perspective does not allow multiple data !\n"
             text += "Please select only one Data.\n"
         text_ctrl = wx.TextCtrl(self, -1, str(text), style=wx.TE_MULTILINE,
-                                size=(-1, HEIGHT/3))
+                                size=(-1, HEIGHT / 3))
         text_ctrl.SetEditable(False)
-        self._sizer_txt.Add(text_ctrl , 1, wx.EXPAND|wx.ALL, 10)
+        self._sizer_txt.Add(text_ctrl, 1, wx.EXPAND | wx.ALL, 10)
         iy = 0
         ix = 0
-        rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name), 
-                                  (10, 10), style= wx.RB_GROUP)
+        rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name),
+                              (10, 10), style=wx.RB_GROUP)
         rbox.SetValue(True)
         self.list_of_ctrl.append((rbox, data_list[0]))
         self._choice_sizer.Add(rbox, (iy, ix), (1, 1),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                               wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         for i in range(1, len(data_list)):
             iy += 1
-            rbox = wx.RadioButton(self._panel, -1, 
+            rbox = wx.RadioButton(self._panel, -1,
                                   str(data_list[i].name), (10, 10))
             rbox.SetValue(False)
             self.list_of_ctrl.append((rbox, data_list[i]))
             self._choice_sizer.Add(rbox, (iy, ix),
-                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                                   (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         self._panel.SetSizer(self._choice_sizer)
-        #add sizer
-        self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        # add sizer
+        self._sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
         self._sizer_button.Add(button_cancel, 0,
-                          wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+                               wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
         button_OK = wx.Button(self, wx.ID_OK, "Ok")
         button_OK.SetFocus()
         self._sizer_button.Add(button_OK, 0,
-                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+                               wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
         static_line = wx.StaticLine(self, -1)
-        
-        self._sizer_txt.Add(self._panel, 0, wx.EXPAND|wx.ALL, 5)
-        self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND|wx.ALL, 5)
+
+        self._sizer_txt.Add(self._panel, 0, wx.EXPAND | wx.ALL, 5)
+        self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND | wx.ALL, 5)
         self._sizer_main.Add(static_line, 0, wx.EXPAND, 0)
-        self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10)
-        
-        
+        self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND | wx.ALL, 10)
+
     def get_data(self):
         """
@@ -168,7 +163,3 @@
             rbox, data = item
             if rbox.GetValue():
-                return data 
-
-    
-
- 
+                return data
Index: src/sas/perspectives/invariant/report_dialog.py
===================================================================
--- src/sas/perspectives/invariant/report_dialog.py	(revision e8bb5b62d717c7b44481a4b621030699e4efdaf4)
+++ src/sas/perspectives/invariant/report_dialog.py	(revision 78a205ad60ae50caaa91008f0d11b7bb5353d84d)
@@ -1,32 +1,33 @@
 
 ################################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation. 
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
 #
-#See the license text in license.txt
+# See the license text in license.txt
 #
-#copyright 2009, University of Tennessee
+# copyright 2009, University of Tennessee
 ################################################################################
 
 """
-Dialog report panel to show and summarize the results of 
+Dialog report panel to show and summarize the results of
 the invariant calculation.
 """
 import wx
 import os
-import wx.html as html
- 
+import sys
+import logging
+
 from sas.guiframe.report_dialog import BaseReportDialog
 
 class ReportDialog(BaseReportDialog):
     """
-    The report dialog box. 
+    The report dialog box.
     """
-    
-    def __init__(self,  report_list, *args, **kwds):
+
+    def __init__(self, report_list, *args, **kwds):
         """
         Initialization. The parameters added to Dialog are:
-        
+
         :param report_list: list of html_str, text_str, image
         from invariant_state
@@ -46,9 +47,9 @@
         Save
         """
-        #todo: complete saving fig file and as a txt file
+        # todo: complete saving fig file and as a txt file
         dlg = wx.FileDialog(self, "Choose a file",
                             wildcard=self.wild_card,
-                            style=wx.SAVE|wx.OVERWRITE_PROMPT|wx.CHANGE_DIR)
-        dlg.SetFilterIndex(0) #Set .html files to be default
+                            style=wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR)
+        dlg.SetFilterIndex(0)  # Set .html files to be default
 
         if dlg.ShowModal() != wx.ID_OK:
@@ -57,6 +58,6 @@
 
         fName = dlg.GetPath()
-        ext_num = dlg.GetFilterIndex()  
-        #set file extensions  
+        ext_num = dlg.GetFilterIndex()
+        # set file extensions
         if ext_num == (0 + 2 * self.index_offset):
             # TODO: Sort this case out
@@ -66,5 +67,5 @@
             dlg.Destroy()
 
-            #pic (png) file path/name
+            # pic (png) file path/name
             pic_fname = os.path.splitext(fName)[0] + img_ext
             # save the image for use with pdf writer
@@ -73,5 +74,5 @@
             # put the image file path in the html data
             html = self.report_list[0] % str(pic_fname)
-            
+
             # make/open file in case of absence
             f = open(fName, 'w')
@@ -79,18 +80,18 @@
             # write pdf as a pdf file
             pdf = self.HTML2PDF(data=html, filename=fName)
-            
-            #open pdf
+
+            # open pdf
             if pdf:
                 try:
-                    #Windows
+                    # Windows
                     os.startfile(str(fName))
                 except:
                     try:
-                        #Mac
-                        os.system("open %s"% fName)
+                        # Mac
+                        os.system("open %s" % fName)
                     except:
-                        #DO not open
-                        pass
-            #delete image file
+                        # DO not open
+                        logging.error("Could not open file: %s" % sys.exc_value)
+            # delete image file
             os.remove(pic_fname)
             return
@@ -100,5 +101,5 @@
             report_frame = self.report_list[0]
         elif ext_num == (2 - self.index_offset):
-            ext = '.txt'   
+            ext = '.txt'
             # changing the image extension actually changes the image
             # format on saving
@@ -108,10 +109,10 @@
             return
 
-        #file name     
+        # file name
         fName = os.path.splitext(fName)[0] + ext
         dlg.Destroy()
-        #pic (png) file path/name
+        # pic (png) file path/name
         pic_fname = os.path.splitext(fName)[0] + img_ext
-        #put the image path in html string
+        # put the image path in html string
         if ext_num == (1 - self.index_offset):
             report = report_frame % os.path.basename(pic_fname)
@@ -120,5 +121,4 @@
         f.write(report)
         f.close()
-        #save png file using pic_fname
+        # save png file using pic_fname
         self.report_list[2].savefig(pic_fname)
-        
