editors/Viewer.py
branchwx.NewID_abuse_fix
changeset 2555 5dce99e69027
parent 2494 a30dfc8a0c29
child 2556 f07d389772fd
equal deleted inserted replaced
2554:45d4f9a84c60 2555:5dce99e69027
   449             else:
   449             else:
   450                 child_path = child_name
   450                 child_path = child_name
   451             if len(child_dimensions) > 0:
   451             if len(child_dimensions) > 0:
   452                 child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions])
   452                 child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions])
   453                 child_name += "[]"
   453                 child_name += "[]"
   454             new_id = wx.NewId()
   454             item = menu.Append(wx.ID_ANY, help='', kind=wx.ITEM_NORMAL, text=child_name)
   455             AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name)
   455             self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), item)
   456             self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id)
       
   457             if len(child_tree) > 0:
   456             if len(child_tree) > 0:
   458                 new_id = wx.NewId()
       
   459                 child_menu = wx.Menu(title='')
   457                 child_menu = wx.Menu(title='')
   460                 self.GenerateTreeMenu(x, y, scaling, child_menu, child_path, var_class, child_tree)
   458                 self.GenerateTreeMenu(x, y, scaling, child_menu, child_path, var_class, child_tree)
   461                 menu.AppendMenu(new_id, "%s." % child_name, child_menu)
   459                 menu.AppendMenu(wx.ID_ANY, "%s." % child_name, child_menu)
   462 
   460 
   463     def GetAddVariableBlockFunction(self, x, y, scaling, var_class, var_name, var_type):
   461     def GetAddVariableBlockFunction(self, x, y, scaling, var_class, var_name, var_type):
   464         def AddVariableFunction(event):
   462         def AddVariableFunction(event):
   465             self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type)
   463             self.ParentWindow.AddVariableBlock(x, y, scaling, var_class, var_name, var_type)
   466         return AddVariableFunction
   464         return AddVariableFunction
  1632 
  1630 
  1633     def PopupForceMenu(self):
  1631     def PopupForceMenu(self):
  1634         iec_path = self.GetElementIECPath(self.SelectedElement)
  1632         iec_path = self.GetElementIECPath(self.SelectedElement)
  1635         if iec_path is not None:
  1633         if iec_path is not None:
  1636             menu = wx.Menu(title='')
  1634             menu = wx.Menu(title='')
  1637             new_id = wx.NewId()
  1635             item = menu.Append(wx.ANY_ID, help='', kind=wx.ITEM_NORMAL, text=_("Force value"))
  1638             AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value"))
  1636             self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.SelectedElement), item)
  1639             self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.SelectedElement), id=new_id)
  1637             ritem = menu.Append(wx.ANY_ID, help='', kind=wx.ITEM_NORMAL, text=_("Release value"))
  1640             new_id = wx.NewId()
  1638             self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), ritem)
  1641             AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value"))
       
  1642             self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id)
       
  1643             if self.SelectedElement.IsForced():
  1639             if self.SelectedElement.IsForced():
  1644                 menu.Enable(new_id, True)
  1640                 ritem.Enable(True)
  1645             else:
  1641             else:
  1646                 menu.Enable(new_id, False)
  1642                 ritem.Enable(False)
  1647             if self.Editor.HasCapture():
  1643             if self.Editor.HasCapture():
  1648                 self.Editor.ReleaseMouse()
  1644                 self.Editor.ReleaseMouse()
  1649             self.Editor.PopupMenu(menu)
  1645             self.Editor.PopupMenu(menu)
  1650             menu.Destroy()
  1646             menu.Destroy()
  1651 
  1647