Disable Up and Down buttons when not useful
authorlaurent
Wed, 16 Dec 2009 14:36:44 +0100
changeset 496 5ff24ccff2c7
parent 495 d1c9517c0fe0
child 497 3db9ffa8d816
Disable Up and Down buttons when not useful
VariablePanel.py
--- a/VariablePanel.py	Wed Dec 16 14:25:35 2009 +0100
+++ b/VariablePanel.py	Wed Dec 16 14:36:44 2009 +0100
@@ -654,6 +654,7 @@
             table_length = len(self.Table.data)
             row_class = None
             row_edit = True
+            row = 0
             if table_length > 0:
                 row = self.VariablesGrid.GetGridCursorRow()
                 row_edit = self.Table.GetValueByName(row, "Edit")
@@ -661,8 +662,8 @@
                     row_class = self.Table.GetValueByName(row, "Class")
             self.AddButton.Enable(not self.PouIsUsed or self.Filter not in ["Interface", "Input", "Output", "InOut"])
             self.DeleteButton.Enable(table_length > 0 and row_edit and row_class not in ["Input", "Output", "InOut"])
-            self.UpButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
-            self.DownButton.Enable(table_length > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
+            self.UpButton.Enable(table_length > 0 and row > 0 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
+            self.DownButton.Enable(table_length > 0 and row < table_length - 1 and self.Filter == "All" and row_class not in ["Input", "Output", "InOut"])
 
     def OnAddButton(self, event):
         new_row = self.DefaultValue.copy()