Index: sansguiframe/src/sans/guiframe/data_processor.py
===================================================================
--- sansguiframe/src/sans/guiframe/data_processor.py	(revision 1ec979d732911be4cd0974ba5e4c7bd179575eac)
+++ sansguiframe/src/sans/guiframe/data_processor.py	(revision 08dc9e87d5fc3856c94f96b24f2922d5c014047b)
@@ -54,5 +54,9 @@
         for label in  list:
             label_pos =  elt.find(label)
-            if label_pos != -1:
+            separator_pos  = label_pos + len(label)
+            if label_pos != -1 and len(elt) >= separator_pos  and\
+                elt[separator_pos]== "[":
+                # the label contain , meaning the range selected is not 
+                # continuous
                 if elt.count(',') > 0:
                     new_temp = []
@@ -66,11 +70,13 @@
                     temp_arr += new_temp
                 else:
+                    # continuous range
                     temp = elt.split(label)
                     for item in temp:
-                        range_pos = item.find(":")
-                        if range_pos != -1:
-                            rang = p2.findall(item)
-                            for i in xrange(int(rang[0]), int(rang[1])+1 ):
-                                temp_arr.append(i)
+                        if item.strip() != "":
+                            range_pos = item.find(":")
+                            if range_pos != -1:
+                                rang = p2.findall(item)
+                                for i in xrange(int(rang[0]), int(rang[1])+1 ):
+                                    temp_arr.append(i)
                 col_dict[elt] = (label, temp_arr)
     return col_dict
@@ -148,12 +154,22 @@
         event.Skip()
         if not flag:
+            self.selected_cols = []
+            self.selected_rows = []
             self.selected_cells = []
+            self.axis_label = ""
             self.axis_value = []
-            self.axis_label = ""
+            self.plottable_list = []
+            self.plottable_cells = []
+            self.plottable_flag = False
+        self.last_selected_col = col
+        self.last_selected_row = row
         if col >= 0:
-             self.axis_label = self.GetCellValue(0, col)
+            label_row = 0
+            self.axis_label = self.GetCellValue(label_row, col)
+            self.selected_cols.append(col)
         if cell not in self.selected_cells:
             if row > 0:
                 self.selected_cells.append(cell)
+                self.selected_rows.append(row)
         else:
             if flag:
@@ -163,6 +179,5 @@
             if cell_row > 0 and cell_row < self.max_row_touse:
                 self.axis_value.append(self.GetCellValue(cell_row, cell_col))
-        
-    
+
                 
     def on_left_click(self, event):
@@ -179,4 +194,5 @@
             self.selected_cells = []
             self.axis_label = ""
+            self.axis_value = []
             self.plottable_list = []
             self.plottable_cells = []
@@ -194,4 +210,7 @@
                     if cell not in self.selected_cells:
                         self.selected_cells.append(cell)
+                    else:
+                        if flag:
+                             self.selected_cells.remove(cell)
             self.selected_cols.append(col)
             self.axis_value = []
@@ -506,20 +525,27 @@
     def on_edit_axis(self):
         """
-        Return the select cell of a given selected column
+        Return the select cell of a given selected column. Check that all cells
+        are from the same column
         """
         pos = self.GetSelection()
         grid = self.GetPage(pos)
-        if len(grid.selected_cols) > 1:
-            msg = "Edit axis doesn't understand this selection.\n"
-            msg += "Please select only one column"
+        if len(grid.selected_cols) >= 1:
+            col = grid.selected_cols[0]
+            for c in grid.selected_cols:
+                if c != col:
+                    msg = "Edit axis doesn't understand this selection.\n"
+                    msg += "Please select only one column"
+                    raise ValueError, msg
+            for (cell_row, cell_col) in grid.selected_cells:
+                if cell_col != col:
+                    msg = "Cannot use cells from different columns for "
+                    msg += "this operation.\n"
+                    msg += "Please select elements of the same col.\n"
+                    raise ValueError, msg
+        else:
+            msg = "No item selected.\n"
+            msg += "Please select only one column or one cell"
             raise ValueError, msg
-        if len(grid.selected_cols) == 1:
-            col = grid.selected_cols[0]
-            if len(grid.selected_cells) > 0:
-                cell_row, cell_col = grid.selected_cells[0]
-                if cell_col  != col:
-                    msg = "Edit axis doesn't understand this selection.\n"
-                    msg += "Please select element of the same col"
-                    raise ValueError, msg
+       
         return grid.selected_cells
        
@@ -561,6 +587,6 @@
                 else:
                     result = str(col_name) +  "[" + str(row_min) + ":"
-                    result += str(col_name) + str(row_max) + "]"
-            return result
+                    result += str(row_max) + "]"
+            return str(result)
             
         if len(cell_list) > 0:
@@ -583,5 +609,5 @@
                         if row != new_row:
                             temp_list.insert(index, (None, None))
-                            if index -1 >=0:
+                            if index -1 >= 0:
                                 new_row, _ = temp_list[index-1]
                                 label += create_label(col_name, None, new_row +1)
@@ -827,9 +853,9 @@
         if grid is not None:
             column_names = self.notebook.get_column_labels()
-        #evalue x
+        #evaluate x
         sentence = self.x_axis_label.GetValue()
         try:
             if sentence.strip() == "":
-                msg = "Select column values for x axis and y axis"
+                msg = "Select column values for x axis"
                 raise ValueError, msg
         except:
@@ -837,6 +863,5 @@
                              StatusEvent(status=msg, info="error")) 
              return
-        
-        
+
         dict = parse_string(sentence, column_names.keys())
         for tok, (col_name, list) in dict.iteritems():
@@ -862,4 +887,13 @@
             sentence = sentence.replace(key, value)
         y = eval(sentence)
+        if len(x) != len(y) and (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")) 
+            return
+            
         #plotting
         new_plot = Data1D(x=x, y=y)
@@ -959,5 +993,11 @@
         Get the selected column on  the visible grid and set values for axis
         """
-        cell_list = self.notebook.on_edit_axis()
+        try:
+            cell_list = self.notebook.on_edit_axis()
+        except:
+            msg = str(sys.exc_value)
+            wx.PostEvent(self.parent.parent, 
+                             StatusEvent(status=msg, info="error")) 
+            return 
         label, title = self.create_axis_label(cell_list)
         tcrtl = event.GetEventObject()
