--- a/PLCOpenEditor.py Thu Jun 11 08:52:59 2009 +0200
+++ b/PLCOpenEditor.py Mon Jul 06 11:24:37 2009 -0600
@@ -1802,10 +1802,10 @@
menu.AppendMenu(wx.NewId(), "Change POU Type To", change_menu)
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Rename")
- self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRenamePouMenu(ev, item), id=new_id)
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
- self.Bind(wx.EVT_MENU, self.OnRemovePouMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemovePouMenu(ev, item), id=new_id)
self.PopupMenu(menu)
elif type == ITEM_CONFIGURATION:
menu = wx.Menu(title='')
@@ -1814,20 +1814,20 @@
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id)
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
- self.Bind(wx.EVT_MENU, self.OnRemoveConfigurationMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemoveConfigurationMenu(ev, item), id=new_id)
self.PopupMenu(menu)
elif type in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]:
menu = wx.Menu(title='')
new_id = wx.NewId()
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text="Delete")
if type == ITEM_DATATYPE:
- self.Bind(wx.EVT_MENU, self.OnRemoveDataTypeMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemoveDataTypeMenu(ev, item), id=new_id)
elif type == ITEM_TRANSITION:
- self.Bind(wx.EVT_MENU, self.OnRemoveTransitionMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemoveTransitionMenu(ev, item), id=new_id)
elif type == ITEM_ACTION:
- self.Bind(wx.EVT_MENU, self.OnRemoveActionMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemoveActionMenu(ev, item), id=new_id)
elif type == ITEM_RESOURCE:
- self.Bind(wx.EVT_MENU, self.OnRemoveResourceMenu, id=new_id)
+ self.Bind(wx.EVT_MENU, lambda ev: self.OnRemoveResourceMenu(ev, item), id=new_id)
self.PopupMenu(menu)
elif type in ITEMS_UNEDITABLE:
if name == "Data Types":
@@ -2463,8 +2463,7 @@
# Remove Project Elements Functions
#-------------------------------------------------------------------------------
- def OnRemoveDataTypeMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemoveDataTypeMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_DATATYPE:
name = self.TypesTree.GetItemText(selected)
if not self.Controler.DataTypeIsUsed(name, self.Debug):
@@ -2483,14 +2482,12 @@
message.Destroy()
event.Skip()
- def OnRenamePouMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRenamePouMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_POU:
wx.CallAfter(self.TypesTree.EditLabel, selected)
event.Skip()
- def OnRemovePouMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemovePouMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_POU:
name = self.TypesTree.GetItemText(selected)
if not self.Controler.PouIsUsed(name, self.Debug):
@@ -2512,8 +2509,7 @@
message.Destroy()
event.Skip()
- def OnRemoveTransitionMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemoveTransitionMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_TRANSITION:
transition = self.TypesTree.GetItemText(selected)
item = self.TypesTree.GetItemParent(selected)
@@ -2533,8 +2529,7 @@
self.RefreshTypesTree()
event.Skip()
- def OnRemoveActionMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemoveActionMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_ACTION:
action = self.TypesTree.GetItemText(selected)
item = self.TypesTree.GetItemParent(selected)
@@ -2554,8 +2549,7 @@
self.RefreshTypesTree()
event.Skip()
- def OnRemoveConfigurationMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemoveConfigurationMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_CONFIGURATION:
name = self.TypesTree.GetItemText(selected)
self.Controler.ProjectRemoveConfiguration(name)
@@ -2570,8 +2564,7 @@
self.RefreshInstancesTree()
event.Skip()
- def OnRemoveResourceMenu(self, event):
- selected = self.TypesTree.GetSelection()
+ def OnRemoveResourceMenu(self, event, selected):
if self.TypesTree.GetPyData(selected) == ITEM_RESOURCE:
resource = self.TypesTree.GetItemText(selected)
item = self.TypesTree.GetItemParent(selected)