Index: sansguiframe/src/sans/guiframe/data_processor.py
===================================================================
--- sansguiframe/src/sans/guiframe/data_processor.py	(revision 8c347a61193367bd8a75b5a9949e34a45f6b9385)
+++ sansguiframe/src/sans/guiframe/data_processor.py	(revision 9c8f3ade2d878062b81b37cb90dc42808e9d3037)
@@ -18,4 +18,6 @@
 
 class GridPage(sheet.CSheet):
+    """
+    """
     def __init__(self, parent, panel=None):
         """
@@ -23,8 +25,13 @@
         sheet.CSheet.__init__(self, parent)
         self.SetLabelBackgroundColour('#DBD4D4')
+        self.AutoSize()
         self.panel = panel
         self.col_names = []
-        self._cols = 0
-        self._rows = 0
+        self._cols = 50
+        self._rows = 51
+        col_with = 30
+        row_height = 20
+        self.SetColMinimalAcceptableWidth(col_with)
+        self.SetRowMinimalAcceptableHeight(row_height)
         self.SetNumberRows(self._cols)
         self.SetNumberCols(self._rows)
@@ -33,7 +40,8 @@
         self.axis_label = ""
        
-        
     def on_right_click(self, event):
-        print "on double click", event.GetRow(), event.GetCol()
+        """
+        Catch the right click mouse
+        """
         col = event.GetCol()
         if col != -1 and len(self.col_names) > col:
@@ -49,5 +57,4 @@
         wx.EVT_MENU(self, id, self.on_set_x_axis)
         
-        
         id = wx.NewId()
         slicerpop.Append(id, '&Set Y axis', 'Set Y axis')
@@ -58,33 +65,49 @@
         
         
-            
     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)     
             
     def set_data(self, data):
         """
+        Add data to the grid
         """
         if data is None:
             data = {}
         if  len(data) > 0:
+           
+            self._cols = self.GetNumberCols()
+            self._rows = self.GetNumberRows()
             self.data = data
             self.col_names = data.keys()
             self.col_names.sort() 
-            self._cols = len(self.data.keys()) 
-            self._rows = max([len(v) for v in self.data.values()]) 
-            self.SetNumberRows(int(self._rows))
-            self.SetNumberCols(int(self._cols))
-            for index  in range(len(self.col_names)):
-                self.SetColLabelValue(index, str(self.col_names[index]))
-                
+            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 
+                self.AppendCols(new_col_nbr, True)
+            #Add more rows to the grid if necessary  
+            nbr_user_row = len(self.data.values())
+            if nbr_user_row > self._rows + 1:
+                new_row_nbr =  nbr_user_row - self._rows 
+                self.AppendRows(new_row_nbr, True)
+            # add data to the grid    
+            label_row = 0
+            for index  in range(nbr_user_cols):
+                # use the first row of the grid to add user defined labels
+                self.SetCellValue(label_row, index, str(self.col_names[index]))
             col = 0
             for value_list in self.data.values():
-                for row in range(len(value_list)):
+                for row in range(1, len(value_list)):
                     self.SetCellValue(row, col, str(value_list[row]))
                 col += 1
             self.AutoSize()
+           
 
 class Notebook(nb, PanelBase):
@@ -100,11 +123,42 @@
         """
         nb.__init__(self, parent, -1,
-                    style= wx.NB_BOTTOM)
+                    style= wx.aui.AUI_BUTTON_DOWN|wx.aui.AUI_NB_WINDOWLIST_BUTTON|
+                    wx.aui.AUI_NB_DEFAULT_STYLE|
+                    wx.CLIP_CHILDREN)
         PanelBase.__init__(self, parent)
-    
+        self.enable_close_button()
         self.parent = parent
         self.manager = manager
         self.data = data
-        
+        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.on_close_page)
+        
+    def enable_close_button(self):
+        """
+        display the close button on tab for more than 1 tabs else remove the 
+        close button
+        """
+        if self.GetPageCount() <= 1:
+            style = self.GetWindowStyleFlag() 
+            flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+            if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB == flag:
+                style = style & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+                self.SetWindowStyle(style)
+        else:
+            style = self.GetWindowStyleFlag()
+            flag = wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+            if style & wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB != flag:
+                style |= wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB
+                self.SetWindowStyle(style)
+                
+    def on_close_page(self, event):
+        """
+        close the page
+        """
+        if self.GetPageCount() == 1:
+            event.Veto()
+        self.enable_close_button()
+        
+ 
+            
     def set_data(self, data):
         if data is None:
@@ -113,11 +167,33 @@
         grid = GridPage(self, panel=self.parent)
         grid.set_data(data)  
-        self.AddPage(grid, "Batch")
-     
-        
+        self.AddPage(grid, "")
+        pos = self.GetPageIndex(grid)
+        title = "Batch " + str(self.GetPageCount())
+        self.SetPageText(pos, title)
+        
+    def add_column(self):
+        """
+        Append a new column to the grid
+        """
+        pos = self.GetSelection()
+        grid = self.GetPage(pos)
+        grid.AppendCols(1, True)
+        
+    def on_remove_column(self):
+        """
+        Remove column to the current grid
+        """
+        pos = self.GetSelection()
+        grid = self.GetPage(pos)
+        cols_pos = grid.GetSelectedCols() 
+        for cpos in cols_pos:
+            grid.DeleteCols(cpos)
+          
+          
 class SPanel(ScrolledPanel):
     def __init__(self, parent, *args, **kwds):
         ScrolledPanel.__init__(self, parent , *args, **kwds)
         self.SetupScrolling()  
+
 
 class GridPanel(SPanel):
@@ -236,6 +312,14 @@
         
     def add_column(self):
+        """
+        """
         if self.grid is not None:
             self.grid.add_column()
+        
+    def on_remove_column(self):
+        """
+        """
+        if self.grid is not None:
+            self.grid.on_remove_column()
         
         
@@ -246,13 +330,15 @@
         self.panel = GridPanel(self, data)
         menubar = wx.MenuBar()
+        self.SetMenuBar(menubar)
         edit = wx.Menu()
-        id_col = wx.NewId()
-        edit.Append(id_col, 'Edit', '' )
-        menubar.Append(edit, "&New column")
-        self.SetMenuBar(menubar)
-        wx.EVT_MENU(self, id_col, self.on_add_column)
+        menubar.Append(edit, "&Edit")
         self.Bind(wx.EVT_CLOSE, self.on_close)
-
-        
+        
+        add_col_menu = edit.Append(wx.NewId(), 'Add Column', 'Add column')
+        wx.EVT_MENU(self, add_col_menu.GetId(), self.on_add_column)
+        remove_col_menu = edit.Append(wx.NewId(), 'Remove Column', 
+                                      'Remove Column')
+        wx.EVT_MENU(self, remove_col_menu.GetId(), self.on_remove_column)
+
     def on_close(self, event):
         """
@@ -260,6 +346,13 @@
         self.Hide()
         
+    def on_remove_column(self, event):
+        """
+        Remove the selected column to the grid
+        """
+        self.panel.on_remove_column()
+        
     def on_add_column(self, event):
         """
+        Append a new column to the grid
         """
         self.panel.add_column()
@@ -281,5 +374,5 @@
             data["index"+str(i)] = [i/j, i*j, i, i+j]
             
-        frame = TestFrame(data=data)
+        frame = GridFrame(data=data)
         frame.Show(True)
     except:
