Index: src/sas/guiframe/data_processor.py
===================================================================
--- src/sas/guiframe/data_processor.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/guiframe/data_processor.py	(revision 76aed53a2a3a72e935e8e32e0b513acbaaf7b492)
@@ -10,11 +10,10 @@
 import copy
 from wx.lib.scrolledpanel import ScrolledPanel
-import  wx.grid as  Grid
 import wx.aui
 from wx.aui import AuiNotebook as nb
 import wx.lib.sheet as sheet
 from sas.guiframe.panel_base import PanelBase
-from sas.guiframe.events import NewPlotEvent 
-from sas.guiframe.events import StatusEvent  
+from sas.guiframe.events import NewPlotEvent
+from sas.guiframe.events import StatusEvent
 from sas.plottools import plottables
 from sas.guiframe.dataFitting import Data1D
@@ -23,8 +22,8 @@
              "pow": "math.sqrt"}
 
-class BatchCell:
+class BatchCell(object):
     """
     Object describing a cell in  the grid.
-    
+
     """
     def __init__(self):
@@ -34,5 +33,5 @@
         self.row = -1
         self.object = []
-        
+
 
 def parse_string(sentence, list):
@@ -42,5 +41,4 @@
     :param list: list of columns label
     """
-    toks = []
     p2 = re.compile(r'\d+')
     p = re.compile(r'[\+\-\*\%\/]')
@@ -51,8 +49,8 @@
         temp_arr = []
         for label in  list:
-            label_pos =  elt.find(label)
-            separator_pos  = label_pos + len(label)
+            label_pos = elt.find(label)
+            separator_pos = label_pos + len(label)
             if label_pos != -1 and len(elt) >= separator_pos  and\
-                elt[separator_pos]== "[":
+                elt[separator_pos] == "[":
                 # the label contain , meaning the range selected is not 
                 # continuous
@@ -64,5 +62,5 @@
                         if range_pos != -1:
                             rang = p2.findall(item)
-                            for i in xrange(int(rang[0]), int(rang[1])+1 ):
+                            for i in xrange(int(rang[0]), int(rang[1]) + 1):
                                 new_temp.append(i)
                     temp_arr += new_temp
@@ -75,16 +73,15 @@
                             if range_pos != -1:
                                 rang = p2.findall(item)
-                                for i in xrange(int(rang[0]), int(rang[1])+1 ):
+                                for i in xrange(int(rang[0]), int(rang[1]) + 1):
                                     temp_arr.append(i)
                 col_dict[elt] = (label, temp_arr)
     return col_dict
 
-          
-          
+
 class SPanel(ScrolledPanel):
     def __init__(self, parent, *args, **kwds):
-        ScrolledPanel.__init__(self, parent , *args, **kwds)
-        self.SetupScrolling()  
-        
+        ScrolledPanel.__init__(self, parent, *args, **kwds)
+        self.SetupScrolling()
+
 class GridPage(sheet.CSheet):
     """
@@ -94,5 +91,5 @@
         """
         sheet.CSheet.__init__(self, parent)
-        
+
         self.AdjustScrollbars()
         #self.SetLabelBackgroundColour('#DBD4D4')
@@ -132,5 +129,5 @@
         self.EnableEditing(True)
         if self.GetNumberCols() > 0:
-            self.default_col_width =  self.GetColSize(0)
+            self.default_col_width = self.GetColSize(0)
         self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click)
         self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click)
@@ -138,9 +135,9 @@
         self.Bind(wx.grid.EVT_GRID_CMD_CELL_CHANGE, self.on_edit_cell)
         self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.onContextMenu)
-        
+
     def on_edit_cell(self, event):
         """
         """
-        row, col = event.GetRow(), event.GetCol()
+        row, _ = event.GetRow(), event.GetCol()
         if row > self.max_row_touse:
             self.max_row_touse = row
@@ -148,5 +145,5 @@
             self.data = {}
         event.Skip()
-        
+
     def on_selected_cell(self, event):
         """
@@ -154,5 +151,5 @@
         """
         flag = event.CmdDown() or event.ControlDown()
-        flag_shift =  event.ShiftDown()
+        flag_shift = event.ShiftDown()
         row, col = event.GetRow(), event.GetCol()
         cell = (row, col)
@@ -181,11 +178,11 @@
             else:
                 min_r = min(self.selected_rows)
-            for row_s in range(min_r, row+1):
+            for row_s in range(min_r, row + 1):
                 cel = (row_s, col)
                 if cel not in self.selected_cells:
                     if row > 0:
                         self.selected_cells.append(cel)
-                        self.selected_rows.append(row) 
-            for row_s in self.selected_rows: 
+                        self.selected_rows.append(row)
+            for row_s in self.selected_rows:
                 cel = (row_s, col)
                 if row_s > row:
@@ -200,5 +197,5 @@
         elif flag:
             if cell not in self.selected_cells:
-                if row > 0 :
+                if row > 0:
                     self.selected_cells.append(cell)
                     self.selected_rows.append(row)
@@ -226,9 +223,9 @@
         event.Skip()
         flag = event.CmdDown() or event.ControlDown()
-        
+
         col = event.GetCol()
         row = event.GetRow()
 
-        if not (flag):
+        if not flag:
             self.selected_cols = []
             self.selected_rows = []
@@ -239,12 +236,12 @@
             self.plottable_cells = []
             self.plottable_flag = False
-       
+
         self.last_selected_col = col
         self.last_selected_row = row
         if row != -1 and row not in self.selected_rows:
-             self.selected_rows.append(row)
-             
+            self.selected_rows.append(row)
+
         if col != -1:
-            for row in range(1, self.GetNumberRows()+ 1):
+            for row in range(1, self.GetNumberRows() + 1):
                 cell = (row, col)
                 if row > 0 and row < self.max_row_touse:
@@ -253,5 +250,5 @@
                     else:
                         if flag:
-                             self.selected_cells.remove(cell)
+                            self.selected_cells.remove(cell)
             self.selected_cols.append(col)
             self.axis_value = []
@@ -263,10 +260,9 @@
             if not self.axis_label:
                 self.axis_label = " "
-        
+
     def on_right_click(self, event):
         """
         Catch the right click mouse
         """
-        
         col = event.GetCol()
         row = event.GetRow()
@@ -278,35 +274,27 @@
         # Slicer plot popup menu
         slicerpop = wx.Menu()
-        col_label_menu  = wx.Menu()
-        c_name = self.GetCellValue(0, col) 
+        col_label_menu = wx.Menu()
+        c_name = self.GetCellValue(0, col)
         label = "Insert column before %s " % str(c_name)
-        slicerpop.AppendSubMenu(col_label_menu , 
-                                 '&%s' % str(label), str(label))
-        col_name = [self.GetCellValue(0, c) 
-                        for c in range(self.GetNumberCols())]
+        slicerpop.AppendSubMenu(col_label_menu, '&%s' % str(label), str(label))
         row = 0
         label = self.GetCellValue(row, col)
         self.insert_col_menu(col_label_menu, label, self)
-        
-        
-        col_after_menu  = wx.Menu()
+
+        col_after_menu = wx.Menu()
         label = "Insert column after %s " % str(c_name)
-        slicerpop.AppendSubMenu(col_after_menu , 
-                                 '&%s' % str(label), str(label))
-        col_name = [self.GetCellValue(0, c) 
-                        for c in range(self.GetNumberCols())]
+        slicerpop.AppendSubMenu(col_after_menu, '&%s' % str(label), str(label))
         self.insert_after_col_menu(col_after_menu, label, self)
-        
-        
-        id = wx.NewId()    
+
+        wx_id = wx.NewId()
         hint = 'Remove selected column %s'
-        slicerpop.Append(id, '&Remove Column', hint)
-        wx.EVT_MENU(self, id, self.on_remove_column)
-        
+        slicerpop.Append(wx_id, '&Remove Column', hint)
+        wx.EVT_MENU(self, wx_id, self.on_remove_column)
+
         pos = wx.GetMousePosition()
         pos = self.ScreenToClient(pos)
         self.PopupMenu(slicerpop, pos)
         event.Skip()
-        
+
     def insert_col_menu(self, menu, label, window):
         """
@@ -320,35 +308,34 @@
         wx.EVT_MENU(window, id, self.on_insert_column)
         row = 0
-        col_name = [self.GetCellValue(row, col) 
+        col_name = [self.GetCellValue(row, col) for col in range(self.GetNumberCols())]
+        for c_name in self.data.keys():
+            if c_name not in col_name and self.data[c_name]:
+                wx_id = wx.NewId()
+                hint = "Insert %s column before the " % str(c_name)
+                hint += " %s column" % str(label)
+                menu.Append(wx_id, '&%s' % str(c_name), hint)
+                wx.EVT_MENU(window, wx_id, self.on_insert_column)
+
+    def insert_after_col_menu(self, menu, label, window):
+        """
+        """
+        if self.data is None:
+            return
+        wx_id = wx.NewId()
+        title = "Empty"
+        hint = 'Insert empty column after %s' % str(label)
+        menu.Append(wx_id, title, hint)
+        wx.EVT_MENU(window, wx_id, self.on_insert_after_column)
+        row = 0
+        col_name = [self.GetCellValue(row, col)
                         for col in range(self.GetNumberCols())]
         for c_name in self.data.keys():
             if c_name not in col_name and self.data[c_name]:
-                id = wx.NewId()
-                hint = "Insert %s column before the " % str(c_name)
-                hint += " %s column" % str(label)
-                menu.Append(id, '&%s' % str(c_name), hint)
-                wx.EVT_MENU(window, id, self.on_insert_column)
-            
-    def insert_after_col_menu(self, menu, label, window):
-        """
-        """
-        if self.data is None:
-            return
-        id = wx.NewId()
-        title = "Empty"
-        hint = 'Insert empty column after %s' % str(label)
-        menu.Append(id, title, hint)
-        wx.EVT_MENU(window, id, self.on_insert_after_column)
-        row = 0
-        col_name = [self.GetCellValue(row, col) 
-                        for col in range(self.GetNumberCols())]
-        for c_name in self.data.keys():
-            if c_name not in col_name and self.data[c_name]:
-                id = wx.NewId()
+                wx_id = wx.NewId()
                 hint = "Insert %s column after the " % str(c_name)
                 hint += " %s column" % str(label)
-                menu.Append(id, '&%s' % str(c_name), hint)
-                wx.EVT_MENU(window, id, self.on_insert_after_column)
-                               
+                menu.Append(wx_id, '&%s' % str(c_name), hint)
+                wx.EVT_MENU(window, wx_id, self.on_insert_after_column)
+
     def on_remove_column(self, event=None):
         """
@@ -357,5 +344,5 @@
             col = self.selected_cols[0]
             self.remove_column(col=col, numCols=1)
-            
+
     def remove_column(self, col, numCols=1):
         """
@@ -370,5 +357,5 @@
                 value = self.GetCellValue(row, col)
                 self.data[col_name].append(value)
-                for k , value_list in self.data.iteritems():
+                for k, value_list in self.data.iteritems():
                     if k != col_name:
                         length = len(value_list)
@@ -378,5 +365,5 @@
                                 self.data[k].append("")
         self.DeleteCols(pos=col, numCols=numCols, updateLabels=True)
-            
+
     def on_insert_column(self, event):
         """
@@ -384,13 +371,12 @@
         if self.selected_cols is not None or len(self.selected_cols) > 0:
             col = self.selected_cols[0]
-            # add data to the grid    
-            row = 0
-            id = event.GetId()
-            col_name = event.GetEventObject().GetLabelText(id)
+            # add data to the grid
+            wx_id = event.GetId()
+            col_name = event.GetEventObject().GetLabelText(wx_id)
             self.insert_column(col=col, col_name=col_name)
-            if  not issubclass(event.GetEventObject().__class__ , wx.Menu):
+            if  not issubclass(event.GetEventObject().__class__, wx.Menu):
                 col += 1
                 self.selected_cols[0] += 1
-                
+
     def on_insert_after_column(self, event):
         """
@@ -399,16 +385,14 @@
         if self.selected_cols is not None or len(self.selected_cols) > 0:
             col = self.selected_cols[0] + 1
-            # add data to the grid    
-            row = 0
-            id = event.GetId()
-            col_name = event.GetEventObject().GetLabelText(id)
+            # add data to the grid
+            wx_id = event.GetId()
+            col_name = event.GetEventObject().GetLabelText(wx_id)
             self.insert_column(col=col, col_name=col_name)
-            if  not issubclass(event.GetEventObject().__class__ , wx.Menu):
+            if  not issubclass(event.GetEventObject().__class__, wx.Menu):
                 self.selected_cols[0] += 1
-           
+
     def insert_column(self, col, col_name):
         """
-        """ 
-         
+        """
         row = 0
         self.InsertCols(pos=col, numCols=1, updateLabels=True)
@@ -417,5 +401,5 @@
         if col_name in self.data.keys():
             value_list = self.data[col_name]
-            cell_row =  1
+            cell_row = 1
             for value in value_list:
                 label = value#format_number(value, high=True)
@@ -425,19 +409,19 @@
         width = self.GetColSize(col)
         if width < self.default_col_width:
-           self.SetColSize(col, self.default_col_width)
+            self.SetColSize(col, self.default_col_width)
         color = self.parent.GetBackgroundColour()
         self.SetCellBackgroundColour(0, col, color)
         self.ForceRefresh()
-        
+
     def on_set_x_axis(self, event):
         """
         """
         self.panel.set_xaxis(x=self.axis_value, label=self.axis_label)
-   
+
     def on_set_y_axis(self, event):
         """
         """
-        self.panel.set_yaxis(y=self.axis_value, label=self.axis_label)     
-            
+        self.panel.set_yaxis(y=self.axis_value, label=self.axis_label)
+
     def set_data(self, data_inputs, data_outputs, details, file_name):
         """
@@ -448,5 +432,5 @@
         self.file_name = file_name
         self.details = details
-        
+
         if data_outputs is None:
             data_outputs = {}
@@ -458,33 +442,29 @@
         for item in (self.data_outputs, self.data_inputs):
             self.data.update(item)
-            
-        #if len(self.data) + len(self.data_inputs) +len(self.data_outputs) == 0:
-        #    self.EnableEditing(False)
-        #else:
-        #    self.EnableEditing(True)
+
         if  len(self.data_outputs) > 0:
             self._cols = self.GetNumberCols()
             self._rows = self.GetNumberRows()
             self.col_names = self.data_outputs.keys()
-            self.col_names.sort() 
+            self.col_names.sort()
             nbr_user_cols = len(self.col_names)
             #Add more columns to the grid if necessary
             if nbr_user_cols > self._cols:
-                new_col_nbr = nbr_user_cols -  self._cols + 1
+                new_col_nbr = nbr_user_cols - self._cols + 1
                 self.AppendCols(new_col_nbr, True)
-            #Add more rows to the grid if necessary  
+            #Add more rows to the grid if necessary
             nbr_user_row = len(self.data_outputs.values()[0])
             if nbr_user_row > self._rows + 1:
-                new_row_nbr =  nbr_user_row - self._rows + 1
+                new_row_nbr = nbr_user_row - self._rows + 1
                 self.AppendRows(new_row_nbr, True)
-            # add data to the grid    
+            # add data to the grid
             wx.CallAfter(self.set_grid_values)
         self.ForceRefresh()
-    
+
     def set_grid_values(self):
         """
         Set the values in grids
         """
-        # add data to the grid    
+        # add data to the grid
         row = 0
         col = 0
@@ -494,7 +474,7 @@
             self.SetCellValue(row, col, str(col_name))
             col += 1
-            cell_row =  1
+            cell_row = 1
             value_list = self.data_outputs[col_name]
-            
+
             for value in value_list:
                 label = value
@@ -510,11 +490,11 @@
                 width = self.GetColSize(cell_col)
                 if width < self.default_col_width:
-                   self.SetColSize(cell_col, self.default_col_width)
-                
+                    self.SetColSize(cell_col, self.default_col_width)
+
                 cell_row += 1
             cell_col += 1
             if cell_row > self.max_row_touse:
                 self.max_row_touse = cell_row
-                         
+
     def get_grid_view(self):
         """
@@ -523,5 +503,5 @@
         grid_view = {}
         for col in xrange(self.GetNumberCols()):
-            label = self.GetCellValue(row=0, col=col) 
+            label = self.GetCellValue(row=0, col=col)
             label = label.strip()
             if label != "":
@@ -530,9 +510,9 @@
                     value = self.GetCellValue(row=row, col=col)
                     if value != "":
-                        grid_view[label].append(value)  
+                        grid_view[label].append(value)
                     else:
-                        grid_view[label].append(None) 
+                        grid_view[label].append(None)
         return grid_view
-    
+
     def get_nofrows(self):
         """
@@ -540,22 +520,22 @@
         """
         return self._rows
-    
+
     def onContextMenu(self, event):
         """
-        Default context menu 
-        """
-        id = wx.NewId()
+        Default context menu
+        """
+        wx_id = wx.NewId()
         c_menu = wx.Menu()
-        copy_menu = c_menu.Append(id, '&Copy', 'Copy the selected cells')
-        wx.EVT_MENU(self, id, self.on_copy)
-        
-        id = wx.NewId()
-        paste_menu = c_menu.Append(id, '&Paste', 'Paste the selected cells')
-        wx.EVT_MENU(self, id, self.on_paste)
-        
-        id = wx.NewId()
-        clear_menu = c_menu.Append(id, '&Clear', 'Clear the selected cells')
-        wx.EVT_MENU(self, id, self.on_clear)
-        
+        copy_menu = c_menu.Append(wx_id, '&Copy', 'Copy the selected cells')
+        wx.EVT_MENU(self, wx_id, self.on_copy)
+
+        wx_id = wx.NewId()
+        c_menu.Append(wx_id, '&Paste', 'Paste the selected cells')
+        wx.EVT_MENU(self, wx_id, self.on_paste)
+
+        wx_id = wx.NewId()
+        clear_menu = c_menu.Append(wx_id, '&Clear', 'Clear the selected cells')
+        wx.EVT_MENU(self, wx_id, self.on_clear)
+
         # enable from flag
         has_selection = False
@@ -576,5 +556,5 @@
         except:
             return
-    
+
     def on_copy(self, event):
         """
@@ -592,5 +572,5 @@
             self.file_name = 'copied_data'
         self.Paste()
-    
+
     def on_clear(self, event):
         """
@@ -598,5 +578,5 @@
         """
         self.Clear()
-    
+
 class Notebook(nb, PanelBase):
     """
@@ -606,12 +586,12 @@
     """
     window_caption = "Notebook "
-    
+
     def __init__(self, parent, manager=None, data=None, *args, **kwargs):
         """
         """
         nb.__init__(self, parent, -1,
-                    style=wx.aui.AUI_NB_WINDOWLIST_BUTTON| 
-                    wx.aui.AUI_BUTTON_DOWN|
-                    wx.aui.AUI_NB_DEFAULT_STYLE|
+                    style=wx.aui.AUI_NB_WINDOWLIST_BUTTON |
+                    wx.aui.AUI_BUTTON_DOWN |
+                    wx.aui.AUI_NB_DEFAULT_STYLE |
                     wx.CLIP_CHILDREN)
         PanelBase.__init__(self, parent)
@@ -624,6 +604,6 @@
         self.add_empty_page()
         self.pageClosedEvent = wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE
-        self.Bind(self.pageClosedEvent, self.on_close_page)    
-    
+        self.Bind(self.pageClosedEvent, self.on_close_page)
+
     def add_empty_page(self):
         """
@@ -637,13 +617,13 @@
         self.enable_close_button()
         self.gpage_num += 1
-        return grid , pos
-        
+        return grid, pos
+
     def enable_close_button(self):
         """
-        display the close button on tab for more than 1 tabs else remove the 
+        display the close button on tab for more than 1 tabs else remove the
         close button
         """
         if self.GetPageCount() <= 1:
-            style = self.GetWindowStyleFlag() 
+            style = self.GetWindowStyleFlag()
             flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
             if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == flag:
@@ -656,5 +636,5 @@
                 style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
                 self.SetWindowStyle(style)
-              
+
     def on_edit_axis(self):
         """
@@ -672,5 +652,5 @@
                     msg += "Please select only one column"
                     raise ValueError, msg
-            for (cell_row, cell_col) in grid.selected_cells:
+            for (_, cell_col) in grid.selected_cells:
                 if cell_col != col:
                     msg = "Cannot use cells from different columns for "
@@ -678,5 +658,5 @@
                     msg += "Please select elements of the same col.\n"
                     raise ValueError, msg
-                
+
             # Finally check the highlighted cell if any cells missing
             self.get_highlighted_row(True)
@@ -686,5 +666,5 @@
             raise ValueError, msg
         return grid.selected_cells
-       
+
     def get_highlighted_row(self, is_number=True):
         """
@@ -706,5 +686,5 @@
                     continue
                 if is_number:
-                    try: 
+                    try:
                         float(grid.GetCellValue(row, col))
                     except:
@@ -715,5 +695,5 @@
                 if cel not in grid.selected_cells:
                     grid.selected_cells.append(cel)
-                        
+
     def get_column_labels(self):
         """
@@ -723,18 +703,16 @@
         grid = self.GetPage(pos)
         labels = {}
-        row = 0
         for col in range(grid.GetNumberCols()):
             label = grid.GetColLabelValue(int(col))
-            #label = grid.GetCellValue(row, col)
-            if label.strip() != "" :
+            if label.strip() != "":
                 labels[label.strip()] = col
         return labels
-        
+
     def create_axis_label(self, cell_list):
         """
-        Receive a list of cells and  create a string presenting the selected 
-        cells. 
+        Receive a list of cells and  create a string presenting the selected
+        cells.
         :param cell_list: list of tuple
-        
+
         """
         pos = self.GetSelection()
@@ -742,5 +720,5 @@
         label = ""
         col_name = ""
-        def create_label(col_name,  row_min=None, row_max=None):
+        def create_label(col_name, row_min=None, row_max=None):
             """
             """
@@ -750,24 +728,24 @@
                     result = str(row_max) + "]"
                 elif row_max is None:
-                     result = str(col_name) + "[" + str(row_min) + ":"
+                    result = str(col_name) + "[" + str(row_min) + ":"
                 else:
-                    result = str(col_name) +  "[" + str(row_min) + ":"
+                    result = str(col_name) + "[" + str(row_min) + ":"
                     result += str(row_max) + "]"
             return str(result)
-            
+
         if len(cell_list) > 0:
             if len(cell_list) == 1:
-                row_min, col  = cell_list[0]    
-                col_name =  grid.GetColLabelValue(int(col))
-                 
+                row_min, col = cell_list[0]
+                col_name = grid.GetColLabelValue(int(col))
+
                 col_title = grid.GetCellValue(0, col)
-                label = create_label(col_name, row_min+1 , row_min+1)
-                return  label,  col_title
+                label = create_label(col_name, row_min + 1, row_min + 1)
+                return  label, col_title
             else:
                 temp_list = copy.deepcopy(cell_list)
                 temp_list.sort()
                 length = len(temp_list)
-                row_min, col  = temp_list[0]    
-                row_max, _  = temp_list[length-1]
+                row_min, col = temp_list[0]
+                row_max, _ = temp_list[length - 1]
                 col_name = grid.GetColLabelValue(int(col))
                 col_title = grid.GetCellValue(0, col)
@@ -779,9 +757,9 @@
                         if row != new_row:
                             temp_list.insert(index, (None, None))
-                            if index -1 >= 0:
-                                new_row, _ = temp_list[index-1]
-                                if not new_row == None and new_row != ' ' :
-                                    label += create_label(col_name, None, 
-                                                          int(new_row) +1)
+                            if index - 1 >= 0:
+                                new_row, _ = temp_list[index - 1]
+                                if not new_row == None and new_row != ' ':
+                                    label += create_label(col_name, None,
+                                                          int(new_row) + 1)
                                 else:
                                     label += "]"
@@ -789,14 +767,14 @@
                             if index + 1 < len(temp_list):
                                 new_row, _ = temp_list[index + 1]
-                                if not new_row==None:
-                                    label += create_label(col_name, 
-                                                          int(new_row)+1, None)
+                                if not new_row == None:
+                                    label += create_label(col_name,
+                                                          int(new_row) + 1, None)
                     if row_min != None and row_max != None:
                         if index == 0:
-                            label += create_label(col_name,  
-                                                  int(row_min)+1, None)
-                        elif index == len(temp_list)-1:
-                            label += create_label(col_name, None, 
-                                                  int(row_max)+1)
+                            label += create_label(col_name,
+                                                  int(row_min) + 1, None)
+                        elif index == len(temp_list) - 1:
+                            label += create_label(col_name, None,
+                                                  int(row_max) + 1)
                     index += 1
                 # clean up the list
@@ -809,5 +787,5 @@
 
                 return label_out, col_title
-    
+
     def on_close_page(self, event):
         """
@@ -817,5 +795,5 @@
             event.Veto()
         wx.CallAfter(self.enable_close_button)
-        
+
     def set_data(self, data_inputs, data_outputs, details="", file_name=None):
         if data_outputs is None or data_outputs == {}:
@@ -826,17 +804,17 @@
             if grid.data is None:
                 #Found empty page
-                grid.set_data(data_inputs=inputs, 
+                grid.set_data(data_inputs=inputs,
                               data_outputs=outputs,
                               details=details,
-                              file_name=file_name) 
-                self.SetSelection(pos) 
+                              file_name=file_name)
+                self.SetSelection(pos)
                 return
-                
+
         grid, pos = self.add_empty_page()
-        grid.set_data(data_inputs=inputs, 
+        grid.set_data(data_inputs=inputs,
                       data_outputs=outputs,
                       file_name=file_name,
                       details=details)
-        
+
     def get_odered_results(self, inputs, outputs=None):
         """
@@ -868,8 +846,7 @@
             else:
                 inputs[key] = []
-                #print "Different length in %s: Removed from Listing."% key
-                
+
         return inputs, outputs
-    
+
     def add_column(self):
         """
@@ -879,5 +856,5 @@
         grid = self.GetPage(pos)
         grid.AppendCols(1, True)
-        
+
     def on_remove_column(self):
         """
@@ -887,12 +864,12 @@
         grid = self.GetPage(pos)
         grid.on_remove_column(event=None)
-        
+
 class GridPanel(SPanel):
     def __init__(self, parent, data_inputs=None,
                  data_outputs=None, *args, **kwds):
-        SPanel.__init__(self, parent , *args, **kwds)
-       
+        SPanel.__init__(self, parent, *args, **kwds)
+
         self.vbox = wx.BoxSizer(wx.VERTICAL)
-        
+
         self.plotting_sizer = wx.FlexGridSizer(3, 7, 10, 5)
         self.button_sizer = wx.BoxSizer(wx.HORIZONTAL)
@@ -906,6 +883,6 @@
         self._data_outputs = data_outputs
         self.x = []
-        self.y  = []
-        self.dy  = []
+        self.y = []
+        self.dy = []
         self.x_axis_label = None
         self.y_axis_label = None
@@ -919,5 +896,5 @@
         self.notebook = None
         self.plot_num = 1
-       
+
         self.layout_grid()
         self.layout_plotting_area()
@@ -932,5 +909,5 @@
         self.x_axis_label.SetValue("%s[:]" % str(label))
         self.x_axis_title.SetValue(str(label))
-        
+
     def set_yaxis(self, label="", y=None):
         """
@@ -941,5 +918,5 @@
         self.y_axis_label.SetValue("%s[:]" % str(label))
         self.y_axis_title.SetValue(str(label))
-        
+
     def set_dyaxis(self, label="", dy=None):
         """
@@ -949,8 +926,8 @@
         self.dy = dy
         self.dy_axis_label.SetValue("%s[:]" % str(label))
-                
+
     def get_plot_axis(self, col, list):
         """
-       
+
         """
         axis = []
@@ -967,13 +944,12 @@
                         axis.append(float(value))
                     except:
-                        msg = "Invalid data in row %s column %s" % (str(row),
-                                                                    str(col))
-                        wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error"))
+                        msg = "Invalid data in row %s column %s" % (str(row), str(col))
+                        wx.PostEvent(self.parent.parent,
+                                     StatusEvent(status=msg, info="error"))
                         return None
             else:
-                axis.append(None) 
+                axis.append(None)
         return axis
-    
+
     def on_view(self, event):
         """
@@ -986,13 +962,11 @@
         if len(grid.selected_cells) == 0:
             msg = "Highlight a Data or Chi2 column first..."
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         elif len(grid.selected_cells) > 20:
             msg = "Too many data (> 20) to plot..."
             msg += "\n Please select no more than 20 data."
-            dial = wx.MessageDialog(self, msg, 'Plotting', wx.OK)
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            wx.MessageDialog(self, msg, 'Plotting', wx.OK)
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
 
@@ -1004,10 +978,9 @@
                 values = grid.data[label]
                 if row > len(values) or row < 1:
-                    msg = "Invalid cell was chosen." 
-                    wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
-                                                                info="error"))
+                    msg = "Invalid cell was chosen."
+                    wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
                     continue
                 else:
-                     value = values[row -1]
+                    value = values[row - 1]
                 if issubclass(value.__class__, BatchCell):
                     if value.object is None or len(value.object) == 0:
@@ -1015,21 +988,16 @@
                         msg += "Column %s is NOT " % str(label)
                         msg += "the results of fits to view..."
-                        #raise ValueError, msg
-                        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, 
-                                                                info="error")) 
+                        wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
                         return
                     for new_plot in value.object:
                         if new_plot is None or \
-                         not issubclass(new_plot.__class__, 
+                         not issubclass(new_plot.__class__,
                                         plottables.Plottable):
                             msg = "Row %s , " % str(row)
                             msg += "Column %s is NOT " % str(label)
                             msg += "the results of fits to view..."
-                            #raise ValueError, msg
-                            wx.PostEvent(self.parent.parent, 
-                                 StatusEvent(status=msg, info="error")) 
+                            wx.PostEvent(self.parent.parent,
+                                         StatusEvent(status=msg, info="error"))
                             return
-                            #continue
-                        #new_plot.name =  title + ': ' + new_plot.title
                         if issubclass(new_plot.__class__, Data1D):
                             if label in grid.list_plot_panels.keys():
@@ -1046,29 +1014,25 @@
                                     msg = "2D View: Please select one data set"
                                     msg += " at a time for View Fit Results."
-                                    wx.PostEvent(self.parent.parent, 
-                                                 StatusEvent(status=msg,
-                                                              info="error"))
+                                    wx.PostEvent(self.parent.parent,
+                                                 StatusEvent(status=msg, info="error"))
                                     return
 
-                        wx.PostEvent(self.parent.parent, 
-                                     NewPlotEvent(plot=new_plot, 
-                                                group_id=str(new_plot.group_id),
-                                                title=title))  
+                        wx.PostEvent(self.parent.parent,
+                                     NewPlotEvent(plot=new_plot,
+                                                  group_id=str(new_plot.group_id),
+                                                  title=title))
                         msg = "Plotting the View Fit Results  completed!"
-                        wx.PostEvent( self.parent.parent, 
-                                      StatusEvent(status=msg))  
+                        wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
                 else:
-                   
                     msg = "Row %s , " % str(row)
                     msg += "Column %s is NOT " % str(label)
                     msg += "the results of fits to view..."
-                    wx.PostEvent(self.parent.parent, 
-                         StatusEvent(status=msg, info="error")) 
+                    wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
                     return
-    
+
     def on_plot(self, event):
         """
         Evaluate the contains of textcrtl and plot result
-        """ 
+        """
         pos = self.notebook.GetSelection()
         grid = self.notebook.GetPage(pos)
@@ -1084,9 +1048,8 @@
         except:
             msg = "X axis value error."
-            wx.PostEvent(self.parent.parent, 
-                            StatusEvent(status=msg, info="error")) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         dict = parse_string(sentence, column_names.keys())
-        
+
         try:
             sentence = self.get_sentence(dict, sentence, column_names)
@@ -1094,6 +1057,5 @@
         except:
             msg = "Need a proper x-range."
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         #evaluate y
@@ -1105,6 +1067,5 @@
         except:
             msg = "Y axis value error."
-            wx.PostEvent(self.parent.parent, 
-                            StatusEvent(status=msg, info="error")) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         dict = parse_string(sentence, column_names.keys())
@@ -1114,6 +1075,5 @@
         except:
             msg = "Need a proper y-range."
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         #evaluate y
@@ -1127,22 +1087,17 @@
             except:
                 msg = "Need a proper dy-range."
-                wx.PostEvent(self.parent.parent, 
-                                 StatusEvent(status=msg, info="error")) 
+                wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
                 return
         if len(x) != len(y) or (len(x) == 0 or len(y) == 0):
             msg = "Need same length for X and Y axis and both greater than 0"
             msg += " to plot.\n"
-            msg += "Got X length = %s, Y length = %s" % (str(len(x)),
-                                                          str(len(y)))
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            msg += "Got X length = %s, Y length = %s" % (str(len(x)), str(len(y)))
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
-        if dy != None and (len(y) != len(dy)):  
+        if dy != None and (len(y) != len(dy)):
             msg = "Need same length for Y and dY axis and both greater than 0"
             msg += " to plot.\n"
-            msg += "Got Y length = %s, dY length = %s" % (str(len(y)),
-                                                          str(len(dy)))
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
+            msg += "Got Y length = %s, dY length = %s" % (str(len(y)), str(len(dy)))
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
             return
         if dy == None:
@@ -1150,18 +1105,14 @@
         #plotting
         new_plot = Data1D(x=x, y=y, dy=dy)
-        new_plot.id =  wx.NewId()
+        new_plot.id = wx.NewId()
         new_plot.is_data = False
         new_plot.group_id = wx.NewId()
         y_title = self.y_axis_title.GetValue()
         x_title = self.x_axis_title.GetValue()
-        title = "%s_vs_%s" % (y_title, 
-                              x_title)
-        new_plot.xaxis(x_title, 
-                       self.x_axis_unit.GetValue())
-        new_plot.yaxis(y_title, 
-                       self.y_axis_unit.GetValue())
+        title = "%s_vs_%s" % (y_title, x_title)
+        new_plot.xaxis(x_title, self.x_axis_unit.GetValue())
+        new_plot.yaxis(y_title, self.y_axis_unit.GetValue())
         try:
             title = y_title.strip()
-            
             title += "_" + self.notebook.GetPageText(pos)
             title += "_" + str(self.plot_num)
@@ -1169,18 +1120,14 @@
             new_plot.name = title
             new_plot.xtransform = "x"
-            new_plot.ytransform  = "y"  
-            #new_plot.is_data = False
-            wx.PostEvent(self.parent.parent, 
-                        NewPlotEvent(plot=new_plot, 
-                        group_id=str(new_plot.group_id), title =title)) 
+            new_plot.ytransform = "y"
+            wx.PostEvent(self.parent.parent,
+                         NewPlotEvent(plot=new_plot,
+                                      group_id=str(new_plot.group_id), title=title))
             msg = "Plotting completed!"
-            wx.PostEvent( self.parent.parent, 
-                                      StatusEvent(status=msg))  
-            self.parent.parent.update_theory(data_id=new_plot.id, 
-                                              theory=new_plot) 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg))
+            self.parent.parent.update_theory(data_id=new_plot.id, theory=new_plot)
         except:
-             wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
-    
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
+
     def get_sentence(self, dict, sentence, column_names):
         """
@@ -1192,10 +1139,9 @@
             if axis == None:
                 return None
-            sentence = sentence.replace(tok, 
-                                        "numpy.array(%s)" % str(axis))
+            sentence = sentence.replace(tok, "numpy.array(%s)" % str(axis))
         for key, value in FUNC_DICT.iteritems():
             sentence = sentence.replace(key.lower(), value)
         return sentence
-            
+
     def layout_grid(self):
         """
@@ -1205,5 +1151,5 @@
         self.notebook.set_data(self._data_inputs, self._data_outputs)
         self.grid_sizer.Add(self.notebook, 1, wx.EXPAND, 0)
-       
+
     def layout_plotting_area(self):
         """
@@ -1221,12 +1167,12 @@
         self.dy_axis_label = wx.TextCtrl(self, -1, size=(200, -1))
         self.x_axis_add = wx.Button(self, -1, "Add")
-        self.x_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis, 
-                            id=self.x_axis_add.GetId())
+        self.x_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis,
+                             id=self.x_axis_add.GetId())
         self.y_axis_add = wx.Button(self, -1, "Add")
-        self.y_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis, 
-                            id=self.y_axis_add.GetId())
+        self.y_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis,
+                             id=self.y_axis_add.GetId())
         self.dy_axis_add = wx.Button(self, -1, "Add")
-        self.dy_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis, 
-                            id=self.dy_axis_add.GetId())
+        self.dy_axis_add.Bind(event=wx.EVT_BUTTON, handler=self.on_edit_axis,
+                              id=self.dy_axis_add.GetId())
         self.x_axis_unit = wx.TextCtrl(self, -1)
         self.y_axis_unit = wx.TextCtrl(self, -1)
@@ -1238,49 +1184,41 @@
         plot_tip = "Highlight a column for each axis and \n"
         plot_tip += "click the Add buttons first."
-        
+
         self.plot_button.SetToolTipString(plot_tip)
         boxsizer1.AddMany([(note_text, 0, wx.LEFT, 10),
-                           (self.view_button, 0, wx.LEFT|wx.RIGHT, 10)])
-        self.button_sizer.AddMany([(boxsizer1, 0, 
-                                    wx.LEFT|wx.RIGHT|wx.BOTTOM, 10), 
-                                   (self.plot_button, 0, 
-                                    wx.LEFT|wx.TOP|wx.BOTTOM|wx.EXPAND, 12)])
-        
+                           (self.view_button, 0, wx.LEFT | wx.RIGHT, 10)])
+        self.button_sizer.AddMany([(boxsizer1, 0,
+                                    wx.LEFT | wx.RIGHT | wx.BOTTOM, 10),
+                                   (self.plot_button, 0,
+                                    wx.LEFT | wx.TOP | wx.BOTTOM | wx.EXPAND, 12)])
+
         wx.EVT_BUTTON(self, self.plot_button.GetId(), self.on_plot)
-        self.plotting_sizer.AddMany([
-                    (wx.StaticText(self, -1, 
-                                   "X-axis Label\nSelection Range"), 1,
-                      wx.TOP|wx.BOTTOM|wx.LEFT, 10),
-                    (self.x_axis_label, 1, wx.TOP|wx.BOTTOM, 10),
-                    (self.x_axis_add, 1, wx.TOP|wx.BOTTOM|wx.RIGHT, 10),
-                    (wx.StaticText(self, -1, "X-axis Label"), 1, 
-                     wx.TOP|wx.BOTTOM|wx.LEFT, 10),
-                    (self.x_axis_title, 1, wx.TOP|wx.BOTTOM, 10),
-                    (wx.StaticText(self, -1 , "X-axis Unit"), 1, 
-                     wx.TOP|wx.BOTTOM, 10),
-                    (self.x_axis_unit, 1, wx.TOP|wx.BOTTOM, 10),
-                    (wx.StaticText(self, -1, 
-                                   "Y-axis Label\nSelection Range"), 1, 
-                     wx.BOTTOM|wx.LEFT, 10),
+        self.plotting_sizer.AddMany(\
+                   [(wx.StaticText(self, -1, "X-axis Label\nSelection Range"), 1,
+                     wx.TOP | wx.BOTTOM | wx.LEFT, 10),
+                    (self.x_axis_label, 1, wx.TOP | wx.BOTTOM, 10),
+                    (self.x_axis_add, 1, wx.TOP | wx.BOTTOM | wx.RIGHT, 10),
+                    (wx.StaticText(self, -1, "X-axis Label"), 1, wx.TOP | wx.BOTTOM | wx.LEFT, 10),
+                    (self.x_axis_title, 1, wx.TOP | wx.BOTTOM, 10),
+                    (wx.StaticText(self, -1, "X-axis Unit"), 1, wx.TOP | wx.BOTTOM, 10),
+                    (self.x_axis_unit, 1, wx.TOP | wx.BOTTOM, 10),
+                    (wx.StaticText(self, -1, "Y-axis Label\nSelection Range"), 1,
+                     wx.BOTTOM | wx.LEFT, 10),
                     (self.y_axis_label, wx.BOTTOM, 10),
-                    (self.y_axis_add, 1, wx.BOTTOM|wx.RIGHT, 10),
-                    (wx.StaticText(self, -1, "Y-axis Label"), 1, 
-                     wx.BOTTOM|wx.LEFT, 10),
-                    (self.y_axis_title,  wx.BOTTOM, 10),
-                    (wx.StaticText(self, -1 , "Y-axis Unit"), 1, wx.BOTTOM, 10),
+                    (self.y_axis_add, 1, wx.BOTTOM | wx.RIGHT, 10),
+                    (wx.StaticText(self, -1, "Y-axis Label"), 1,
+                     wx.BOTTOM | wx.LEFT, 10),
+                    (self.y_axis_title, wx.BOTTOM, 10),
+                    (wx.StaticText(self, -1, "Y-axis Unit"), 1, wx.BOTTOM, 10),
                     (self.y_axis_unit, 1, wx.BOTTOM, 10),
-                    (wx.StaticText(self, -1, 
-                                   "dY-Bar (Optional)\nSelection Range"),  
-                                   1, wx.BOTTOM|wx.LEFT, 10),
+                    (wx.StaticText(self, -1, "dY-Bar (Optional)\nSelection Range"),
+                     1, wx.BOTTOM | wx.LEFT, 10),
                     (self.dy_axis_label, wx.BOTTOM, 10),
-                    (self.dy_axis_add, 1, wx.BOTTOM|wx.RIGHT, 10),
-                      (-1, -1),
-                      (-1, -1),
-                      (-1, -1),
-                      #(-1, -1),
-                      #(-1, -1),
-                      #(-1, -1),
-                      (-1, 1)])
-   
+                    (self.dy_axis_add, 1, wx.BOTTOM | wx.RIGHT, 10),
+                    (-1, -1),
+                    (-1, -1),
+                    (-1, -1),
+                    (-1, 1)])
+
     def on_edit_axis(self, event):
         """
@@ -1292,28 +1230,24 @@
         except:
             msg = str(sys.exc_value)
-            wx.PostEvent(self.parent.parent, 
-                             StatusEvent(status=msg, info="error")) 
-            return 
+            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error"))
+            return
         tcrtl = event.GetEventObject()
         if tcrtl == self.x_axis_add:
-            self.edit_axis_helper(self.x_axis_label, self.x_axis_title,
-                                   label, title)
+            self.edit_axis_helper(self.x_axis_label, self.x_axis_title, label, title)
         elif tcrtl == self.y_axis_add:
-            self.edit_axis_helper(self.y_axis_label, self.y_axis_title,
-                                   label, title)
+            self.edit_axis_helper(self.y_axis_label, self.y_axis_title, label, title)
         elif tcrtl == self.dy_axis_add:
-            self.edit_axis_helper(self.dy_axis_label, None,
-                                   label, None)
-            
+            self.edit_axis_helper(self.dy_axis_label, None, label, None)
+
     def create_axis_label(self, cell_list):
         """
-        Receive a list of cells and  create a string presenting the selected 
-        cells. 
+        Receive a list of cells and  create a string presenting the selected
+        cells.
         :param cell_list: list of tuple
-        
+
         """
         if self.notebook is not None:
             return self.notebook.create_axis_label(cell_list)
-    
+
     def edit_axis_helper(self, tcrtl_label, tcrtl_title, label, title):
         """
@@ -1324,5 +1258,5 @@
         if title != None:
             tcrtl_title.SetValue(str(title))
-        
+
     def add_column(self):
         """
@@ -1330,5 +1264,5 @@
         if self.notebook is not None:
             self.notebook.add_column()
-        
+
     def on_remove_column(self):
         """
@@ -1336,8 +1270,8 @@
         if self.notebook is not None:
             self.notebook.on_remove_column()
-        
-        
+
+
 class GridFrame(wx.Frame):
-    def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 
+    def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1,
                  title="Grid Window", size=(800, 500)):
         wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size)
@@ -1346,5 +1280,5 @@
         menubar = wx.MenuBar()
         self.SetMenuBar(menubar)
-        
+
         self.curr_col = None
         self.curr_grid = None
@@ -1352,9 +1286,9 @@
         self.file = wx.Menu()
         menubar.Append(self.file, "&File")
-        
+
         hint = "Open file containing batch results"
         open_menu = self.file.Append(wx.NewId(), 'Open ', hint)
         wx.EVT_MENU(self, open_menu.GetId(), self.on_open)
-        
+
         hint = "Open the the current grid into excel"
         self.open_excel_menu = self.file.Append(wx.NewId(), 'Open with Excel', hint)
@@ -1363,19 +1297,19 @@
         self.save_menu = self.file.Append(wx.NewId(), 'Save As', 'Save into File')
         wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page)
-        
+
         self.edit = wx.Menu()
-        
-        add_table_menu = self.edit.Append(-1, 'New Table', 
+
+        add_table_menu = self.edit.Append(-1, 'New Table',
                                           'Add a New Table')
         self.edit.AppendSeparator()
         wx.EVT_MENU(self, add_table_menu.GetId(), self.add_table)
-        
-        self.copy_menu = self.edit.Append(-1, 'Copy', 
+
+        self.copy_menu = self.edit.Append(-1, 'Copy',
                                           'Copy the selected cells')
         wx.EVT_MENU(self, self.copy_menu.GetId(), self.on_copy)
-        self.paste_menu = self.edit.Append(-1, 'Paste', 
+        self.paste_menu = self.edit.Append(-1, 'Paste',
                                            'Paste the selected Cells')
         wx.EVT_MENU(self, self.paste_menu.GetId(), self.on_paste)
-        self.clear_menu = self.edit.Append(-1, 'Clear', 
+        self.clear_menu = self.edit.Append(-1, 'Clear',
                                            'Clear the selected Cells')
         wx.EVT_MENU(self, self.clear_menu.GetId(), self.on_clear)
@@ -1384,18 +1318,18 @@
         hint = "Insert column before the selected column"
         self.insert_before_menu = wx.Menu()
-        self.insertb_sub_menu = self.edit.AppendSubMenu(self.insert_before_menu, 
-                                                      'Insert Before', hint)
+        self.insertb_sub_menu = self.edit.AppendSubMenu(self.insert_before_menu,
+                                                        'Insert Before', hint)
         hint = "Insert column after the selected column"
         self.insert_after_menu = wx.Menu()
-        self.inserta_sub_menu = self.edit.AppendSubMenu(self.insert_after_menu, 
-                                                      'Insert After', hint)
+        self.inserta_sub_menu = self.edit.AppendSubMenu(self.insert_after_menu,
+                                                        'Insert After', hint)
         hint = "Remove the selected column"
         self.remove_menu = self.edit.Append(-1, 'Remove Column', hint)
         wx.EVT_MENU(self, self.remove_menu.GetId(), self.on_remove_column)
-        
+
         self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open)
         menubar.Append(self.edit, "&Edit")
         self.Bind(wx.EVT_CLOSE, self.on_close)
-    
+
     def on_copy(self, event):
         """
@@ -1407,5 +1341,5 @@
         grid = self.panel.notebook.GetPage(pos)
         grid.Copy()
-        
+
     def on_paste(self, event):
         """
@@ -1425,5 +1359,5 @@
         grid = self.panel.notebook.GetPage(pos)
         grid.Clear()
-     
+
     def GetLabelText(self, id):
         """
@@ -1431,8 +1365,8 @@
         """
         for item in self.insert_before_menu.GetMenuItems():
-            m_id = item.GetId() 
+            m_id = item.GetId()
             if m_id == id:
-                return item.GetLabel() 
-    
+                return item.GetLabel()
+
     def on_remove_column(self, event):
         """
@@ -1442,5 +1376,5 @@
         grid = self.panel.notebook.GetPage(pos)
         grid.on_remove_column(event=None)
-        
+
     def on_menu_open(self, event):
         """
@@ -1451,7 +1385,7 @@
             grid = self.panel.notebook.GetPage(pos)
             has_data = (grid.data != None and grid.data != {})
-            self.open_excel_menu.Enable(has_data) 
-            self.save_menu.Enable(has_data) 
-            
+            self.open_excel_menu.Enable(has_data)
+            self.save_menu.Enable(has_data)
+
         if self.edit == event.GetMenu():
             #get the selected column
@@ -1470,5 +1404,5 @@
             self.copy_menu.Enable(has_selection)
             self.clear_menu.Enable(has_selection)
-        
+
             if len(col_list) > 0:
                 self.remove_menu.Enable(True)
@@ -1485,5 +1419,5 @@
                 self.insertb_sub_menu.Enable(True)
                 self.inserta_sub_menu.Enable(True)
-                
+
                 col = col_list[0]
                 col_name = grid.GetCellValue(row=0, col=col)
@@ -1492,5 +1426,5 @@
                 for item in self.insert_before_menu.GetMenuItems():
                     self.insert_before_menu.DeleteItem(item)
-                grid.insert_col_menu(menu=self.insert_before_menu, 
+                grid.insert_col_menu(menu=self.insert_before_menu,
                                      label=col_name, window=self)
                 label = "Insert Column After " + str(col_name)
@@ -1498,10 +1432,10 @@
                 for item in self.insert_after_menu.GetMenuItems():
                     self.insert_after_menu.DeleteItem(item)
-                grid.insert_after_col_menu(menu=self.insert_after_menu, 
-                                     label=col_name, window=self)
+                grid.insert_after_col_menu(menu=self.insert_after_menu,
+                                           label=col_name, window=self)
         event.Skip()
-        
-  
-        
+
+
+
     def on_save_page(self, event):
         """
@@ -1514,14 +1448,14 @@
                 name = self.panel.notebook.GetPageText(pos)
                 msg = " %s has not data to save" % str(name)
-                wx.PostEvent(self.parent, 
-                             StatusEvent(status=msg, info="error")) 
-           
+                wx.PostEvent(self.parent,
+                             StatusEvent(status=msg, info="error"))
+
                 return
             reader, ext = os.path.splitext(grid.file_name)
             path = None
-            if self.parent is not None: 
+            if self.parent is not None:
                 location = os.path.dirname(grid.file_name)
                 dlg = wx.FileDialog(self, "Save Project file",
-                            location, grid.file_name, ext, wx.SAVE)
+                                    location, grid.file_name, ext, wx.SAVE)
                 path = None
                 if dlg.ShowModal() == wx.ID_OK:
@@ -1531,8 +1465,8 @@
                     if self.parent is not None:
                         data = grid.get_grid_view()
-                        self.parent.write_batch_tofile(data=data, 
-                                               file_name=path,
-                                               details=grid.details)
-    
+                        self.parent.write_batch_tofile(data=data,
+                                                       file_name=path,
+                                                       details=grid.details)
+
     def on_open(self, event):
         """
@@ -1541,5 +1475,5 @@
         if self.parent is not None:
             self.parent.on_read_batch_tofile(self)
-            
+
     def open_with_excel(self, event):
         """
@@ -1554,17 +1488,17 @@
                 name = self.panel.notebook.GetPageText(pos)
                 msg = " %s has not data to open on excel" % str(name)
-                wx.PostEvent(self.parent, 
-                             StatusEvent(status=msg, info="error")) 
-           
+                wx.PostEvent(self.parent,
+                             StatusEvent(status=msg, info="error"))
+
                 return
             self.parent.open_with_externalapp(data=data,
-                                              file_name=grid.file_name, 
+                                              file_name=grid.file_name,
                                               details=grid.details)
-            
+
     def on_close(self, event):
         """
         """
         self.Hide()
-        
+
     def on_append_column(self, event):
         """
@@ -1572,13 +1506,13 @@
         """
         self.panel.add_column()
-        
+
     def set_data(self, data_inputs, data_outputs, details="", file_name=None):
         """
         Set data
         """
-        self.panel.notebook.set_data(data_inputs=data_inputs, 
-                            file_name=file_name,
-                            details=details,
-                            data_outputs=data_outputs)
+        self.panel.notebook.set_data(data_inputs=data_inputs,
+                                     file_name=file_name,
+                                     details=details,
+                                     data_outputs=data_outputs)
 
     def add_table(self, event):
@@ -1587,6 +1521,6 @@
         """
         # DO not event.Skip(): it will make 2 pages
-        self.panel.notebook.add_empty_page()      
-      
+        self.panel.notebook.add_empty_page()
+
 class BatchOutputFrame(wx.Frame):
     """
@@ -1597,8 +1531,8 @@
         """
         :param parent: Window instantiating this dialog
-        :param result: result to display in a grid or export to an external 
+        :param result: result to display in a grid or export to an external
                 application.
         """
-        #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 
+        #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU
         wx.Frame.__init__(self, parent, *args, **kwds)
         self.parent = parent
@@ -1617,5 +1551,5 @@
         self.save_to_file = None
         self._do_layout()
-    
+
     def _do_layout(self):
         """
@@ -1627,26 +1561,21 @@
         selection_sizer = wx.GridBagSizer(5, 5)
         button_sizer = wx.BoxSizer(wx.HORIZONTAL)
-        text = "Open with %s" % self.parent.application_name 
-        self.local_app_selected = wx.RadioButton(self.panel, -1, text,
-                                                style=wx.RB_GROUP)
+        text = "Open with %s" % self.parent.application_name
+        self.local_app_selected = wx.RadioButton(self.panel, -1, text, style=wx.RB_GROUP)
         self.Bind(wx.EVT_RADIOBUTTON, self.onselect,
-                    id=self.local_app_selected.GetId())
+                  id=self.local_app_selected.GetId())
         text = "Open with Excel"
-        self.external_app_selected  = wx.RadioButton(self.panel, -1, text)
-        self.Bind(wx.EVT_RADIOBUTTON, self.onselect,
-                    id=self.external_app_selected.GetId())
+        self.external_app_selected = wx.RadioButton(self.panel, -1, text)
+        self.Bind(wx.EVT_RADIOBUTTON, self.onselect, id=self.external_app_selected.GetId())
         text = "Save to File"
         self.save_to_file = wx.CheckBox(self.panel, -1, text)
-        self.Bind(wx.EVT_CHECKBOX, self.onselect,
-                    id=self.save_to_file.GetId())
+        self.Bind(wx.EVT_CHECKBOX, self.onselect, id=self.save_to_file.GetId())
         self.local_app_selected.SetValue(True)
         self.external_app_selected.SetValue(False)
         self.save_to_file.SetValue(False)
         button_close = wx.Button(self.panel, -1, "Close")
-        button_close.Bind(wx.EVT_BUTTON, id=button_close.GetId(),
-                           handler=self.on_close)
+        button_close.Bind(wx.EVT_BUTTON, id=button_close.GetId(), handler=self.on_close)
         button_apply = wx.Button(self.panel, -1, "Apply")
-        button_apply.Bind(wx.EVT_BUTTON, id=button_apply.GetId(),
-                        handler=self.on_apply)
+        button_apply.Bind(wx.EVT_BUTTON, id=button_apply.GetId(), handler=self.on_apply)
         button_apply.SetFocus()
         hint = ""
@@ -1657,23 +1586,23 @@
         iy = 0
         selection_sizer.Add(self.local_app_selected, (iy, ix),
-                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                            (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         iy += 1
         selection_sizer.Add(self.external_app_selected, (iy, ix),
-                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                            (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         iy += 1
         selection_sizer.Add(self.save_to_file, (iy, ix),
-                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                            (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         #contruction the sizer contaning button
-        button_sizer.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        button_sizer.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
 
         button_sizer.Add(button_close, 0,
-                        wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         button_sizer.Add(button_apply, 0,
-                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        vbox.Add(hint_sizer, 0, wx.EXPAND|wx.ALL, 10)
-        vbox.Add(wx.StaticLine(self.panel, -1),  0, wx.EXPAND, 0)
-        vbox.Add(button_sizer, 0, wx.TOP|wx.BOTTOM, 10)
+                         wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        vbox.Add(hint_sizer, 0, wx.EXPAND | wx.ALL, 10)
+        vbox.Add(wx.StaticLine(self.panel, -1), 0, wx.EXPAND, 0)
+        vbox.Add(button_sizer, 0, wx.TOP | wx.BOTTOM, 10)
         self.SetSizer(vbox)
-        
+
     def on_apply(self, event):
         """
@@ -1684,5 +1613,5 @@
                                            data_outputs=self.data_outputs)
         elif self.flag == 2:
-            self.parent.open_with_externalapp(data=self.data, 
+            self.parent.open_with_externalapp(data=self.data,
                                               file_name=self.file_name,
                                               details=self.details)
@@ -1692,19 +1621,19 @@
         """
         self.Close()
-        
+
     def onselect(self, event=None):
         """
         Receive event and display data into third party application
         or save data to file.
-        
+
         """
         if self.save_to_file.GetValue():
-            reader, ext = os.path.splitext(self.file_name)
+            _, ext = os.path.splitext(self.file_name)
             path = None
             location = os.getcwd()
-            if self.parent is not None: 
+            if self.parent is not None:
                 location = os.path.dirname(self.file_name)
                 dlg = wx.FileDialog(self, "Save Project file",
-                            location, self.file_name, ext, wx.SAVE)
+                                    location, self.file_name, ext, wx.SAVE)
                 path = None
                 if dlg.ShowModal() == wx.ID_OK:
@@ -1713,5 +1642,5 @@
                 if path != None:
                     if self.parent is not None and  self.data is not None:
-                        self.parent.write_batch_tofile(data=self.data, 
+                        self.parent.write_batch_tofile(data=self.data,
                                                        file_name=path,
                                                        details=self.details)
@@ -1721,10 +1650,10 @@
             self.flag = 2
         return self.flag
-    
-  
-        
+
+
+
 if __name__ == "__main__":
     app = wx.App()
-   
+
     try:
         data = {}
@@ -1732,7 +1661,7 @@
         for i in range(4):
             j += 1
-            data["index"+str(i)] = [i/j, i*j, i, i+j]
-        
-        data_input =  copy.deepcopy(data)   
+            data["index" + str(i)] = [i / j, i * j, i, i + j]
+
+        data_input = copy.deepcopy(data)
         data_input["index5"] = [10, 20, 40, 50]
         frame = GridFrame(data_outputs=data, data_inputs=data_input)
@@ -1740,4 +1669,4 @@
     except:
         print sys.exc_value
-        
+
     app.MainLoop()
