--- a/PLCOpenEditor.py Wed Dec 16 14:36:44 2009 +0100
+++ b/PLCOpenEditor.py Wed Dec 16 14:53:01 2009 +0100
@@ -4106,7 +4106,12 @@
self.VariablesGrid.SetSelectionBackground(wx.WHITE)
self.VariablesGrid.SetSelectionForeground(wx.BLACK)
self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self))
- self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnVariablesGridRightClick)
+ if wx.VERSION >= (2, 6, 0):
+ self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridCellSelect)
+ self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnVariablesGridCellRightClick)
+ else:
+ wx.grid.EVT_GRID_SELECT_CELL(self.VariablesGrid, self.OnVariablesGridCellSelect)
+ wx.grid.EVT_GRID_CELL_RIGHT_CLICK(self.VariablesGrid, self.OnVariablesGridCellRightClick)
self.UpButton = wx.Button(id=ID_DEBUGVARIABLEPANELUPBUTTON, label='^',
name='UpButton', parent=self, pos=wx.Point(0, 0),
@@ -4141,6 +4146,7 @@
self.VariablesGrid.SetColSize(col, 100)
self.Table.ResetView(self.VariablesGrid)
+ self.RefreshButtons()
def RefreshNewData(self):
if self.HasNewData:
@@ -4174,7 +4180,11 @@
self.ReleaseDataValue(iec_path)
return ReleaseVariableFunction
- def OnVariablesGridRightClick(self, event):
+ def OnVariablesGridCellSelect(self, event):
+ wx.CallAfter(self.RefreshButtons)
+ event.Skip()
+
+ def OnVariablesGridCellRightClick(self, event):
row, col = event.GetRow(), event.GetCol()
if self.Table.GetColLabelValue(col, False) == "Value":
iec_path = self.Table.GetValueByName(row, "Variable").upper()
@@ -4193,6 +4203,16 @@
self.PopupMenu(menu)
event.Skip()
+ def RefreshButtons(self):
+ if getattr(self, "Table", None):
+ table_length = len(self.Table.data)
+ row = 0
+ if table_length > 0:
+ row = self.VariablesGrid.GetGridCursorRow()
+ self.DeleteButton.Enable(table_length > 0)
+ self.UpButton.Enable(table_length > 0 and row > 0)
+ self.DownButton.Enable(table_length > 0 and row < table_length - 1)
+
def OnDeleteButton(self, event):
idx = self.VariablesGrid.GetGridCursorRow()
if idx >= 0:
@@ -4200,6 +4220,7 @@
self.RemoveDataConsumer(item)
self.Table.RemoveItem(idx)
self.RefreshGrid()
+ self.RefreshButtons()
event.Skip()
def OnUpButton(self, event):
@@ -4221,6 +4242,7 @@
if result is not None:
self.Table.InsertItem(idx, item)
self.RefreshGrid()
+ self.RefreshButtons()
def MoveValue(self, idx, move):
new_idx = max(0, min(idx + move, self.Table.GetNumberRows() - 1))
@@ -4228,7 +4250,8 @@
self.Table.MoveItem(idx, new_idx)
self.RefreshGrid()
self.VariablesGrid.SetGridCursor(new_idx, self.VariablesGrid.GetGridCursorCol())
-
+ self.RefreshButtons()
+
#-------------------------------------------------------------------------------
# Viewer Printout
#-------------------------------------------------------------------------------