Viewer.py
changeset 299 15669fe26e56
parent 297 e837b67cb184
child 302 43e10dccc16a
equal deleted inserted replaced
298:1b1a3ee785da 299:15669fe26e56
   174                     message = "Variable don't belong to this POU!"
   174                     message = "Variable don't belong to this POU!"
   175         if message is not None:
   175         if message is not None:
   176             wx.CallAfter(self.ShowMessage, message)
   176             wx.CallAfter(self.ShowMessage, message)
   177 
   177 
   178     def GenerateTreeMenu(self, x, y, scaling, menu, base_path, var_class, tree):
   178     def GenerateTreeMenu(self, x, y, scaling, menu, base_path, var_class, tree):
   179         for child_name, child_type, child_tree in tree:
   179         for child_name, child_type, (child_tree, child_dimensions) in tree:
   180             if base_path:
   180             if base_path:
   181                 child_path = "%s.%s" % (base_path, child_name)
   181                 child_path = "%s.%s" % (base_path, child_name)
   182             else:
   182             else:
   183                 child_path = child_name
   183                 child_path = child_name
   184             if len(child_tree) == 1 and isinstance(child_tree[0], ListType):
   184             if len(child_dimensions) > 0:
   185                 child_path += "[0]"
   185                 child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions])
   186                 child_name += "[]"
   186                 child_name += "[]"
   187                 child_tree = child_tree[0]
       
   188             new_id = wx.NewId()
   187             new_id = wx.NewId()
   189             AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name)
   188             AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name)
   190             self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id)
   189             self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id)
   191             if len(child_tree) > 0:
   190             if len(child_tree) > 0:
   192                 new_id = wx.NewId()
   191                 new_id = wx.NewId()