--- a/PLCOpenEditor.py Sat Jul 21 01:17:02 2007 +0200
+++ b/PLCOpenEditor.py Sat Jul 21 01:20:00 2007 +0200
@@ -790,10 +790,11 @@
if self.ProjectTree.GetPyData(item) == ITEM_POU:
block_name = self.ProjectTree.GetItemText(item)
block_type = self.Controler.GetPouType(block_name)
- data = wxTextDataObject(str((block_name, block_type)))
- dragSource = wxDropSource(self.ProjectTree)
- dragSource.SetData(data)
- dragSource.DoDragDrop()
+ if block_type != "program":
+ data = wxTextDataObject(str((block_name, block_type)))
+ dragSource = wxDropSource(self.ProjectTree)
+ dragSource.SetData(data)
+ dragSource.DoDragDrop()
def OnProjectTreeItemEndEdit(self, event):
message = None
@@ -2036,6 +2037,37 @@
self.data = []
self.editors = []
+class VariableDropTarget(wx.TextDropTarget):
+
+ def __init__(self, parent):
+ wx.TextDropTarget.__init__(self)
+ self.Parent = parent
+
+ def OnDropText(self, x, y, data):
+ col = self.Parent.VariablesGrid.XToCol(x)
+ row = self.Parent.VariablesGrid.YToRow(y)
+ if col != wxNOT_FOUND and row != wxNOT_FOUND:
+ if self.Parent.Table.GetColLabelValue(col) != "Location":
+ return
+ try:
+ values = eval(data)
+ except:
+ values = None
+ if values and values[1] == "location":
+ dialog = wxSingleChoiceDialog(self.Parent, "Select a variable class:", "Variable class", ["Input", "Output", "Memory"], wxOK|wxCANCEL)
+ if dialog.ShowModal() == wxID_OK:
+ selected = dialog.GetSelection()
+ if selected == 0:
+ location = "%I" + values[0]
+ elif selected == 1:
+ location = "%Q" + values[0]
+ else:
+ location = "%M" + values[0]
+ self.Parent.Table.SetValue(row - 1, col, location)
+ self.Parent.Table.ResetView(self.Parent.VariablesGrid)
+ self.Parent.SaveValues()
+ dialog.Destroy()
+
[wxID_POUEDITORPANEL, wxID_POUEDITORPANELVIEWER,
wxID_POUEDITORPANELVARIABLESGRID, wxID_POUEDITORPANELRETURNTYPE,
wxID_POUEDITORPANELCLASSFILTER, wxID_POUEDITORPANELADDBUTTON,
@@ -2185,6 +2217,8 @@
self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridSelectCell)
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick)
+ self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
+
self.AddButton = wx.Button(id=wxID_POUEDITORPANELADDBUTTON, label='Add',
name='AddButton', parent=self, pos=wx.Point(345, 340),
size=wx.Size(72, 32), style=0)