--- a/PLCOpenEditor.py Fri Apr 13 17:10:09 2007 +0200
+++ b/PLCOpenEditor.py Fri Apr 13 17:54:40 2007 +0200
@@ -1929,12 +1929,9 @@
def RemoveRow(self, row_index):
self.data.pop(row_index)
-
- def MoveRow(self, row_index, move, grid):
- new_index = max(0, min(row_index + move, len(self.data) - 1))
- if new_index != row_index:
- self.data.insert(new_index, self.data.pop(row_index))
- grid.SetGridCursor(new_index, grid.GetGridCursorCol())
+
+ def GetRow(self, row_index):
+ return self.data[row_index]
def Empty(self):
self.data = []
@@ -2145,26 +2142,22 @@
new_row["Class"] = self.DefaultTypes[self.Filter]
else:
new_row["Class"] = self.Filter
- self.Table.AppendRow(new_row)
- self.Table.ResetView(self.VariablesGrid)
+ self.Values.append(new_row)
+ self.RefreshValues()
event.Skip()
def OnDeleteButton(self, event):
- row = self.VariablesGrid.GetGridCursorRow()
- self.Table.RemoveRow(row)
- self.Table.ResetView(self.VariablesGrid)
+ row = self.Table.GetRow(self.VariablesGrid.GetGridCursorRow())
+ self.Values.remove(row)
+ self.RefreshValues()
event.Skip()
def OnUpButton(self, event):
- row = self.VariablesGrid.GetGridCursorRow()
- self.Table.MoveRow(row, -1, self.VariablesGrid)
- self.Table.ResetView(self.VariablesGrid)
+ self.MoveValue(self.VariablesGrid.GetGridCursorRow(), -1)
event.Skip()
def OnDownButton(self, event):
- row = self.VariablesGrid.GetGridCursorRow()
- self.Table.MoveRow(row, 1, self.VariablesGrid)
- self.Table.ResetView(self.VariablesGrid)
+ self.MoveValue(self.VariablesGrid.GetGridCursorRow(), 1)
event.Skip()
def OnVariablesGridCellChange(self, event):
@@ -2207,7 +2200,14 @@
if item == "data":
self.Values = value
self.RefreshValues()
-
+
+ def MoveValue(self, value_index, move):
+ new_index = max(0, min(value_index + move, len(self.Values) - 1))
+ if new_index != value_index:
+ self.Values.insert(new_index, self.Values.pop(value_index))
+ self.VariablesGrid.SetGridCursor(new_index, self.VariablesGrid.GetGridCursorCol())
+ self.RefreshValues()
+
def RefreshValues(self):
data = []
for variable in self.Values:
@@ -2220,7 +2220,7 @@
values = {}
if self.ReturnType.IsEnabled():
values["returnType"] = self.ReturnType.GetStringSelection()
- values["data"] = self.Table.GetData()
+ values["data"] = self.Values
return values
#-------------------------------------------------------------------------------