def on_rightclick(self, event):
treeid = event.GetItem()
uid, tree_tid = self.GetItemData(treeid)
UIM = UIManager()
controller = UIM.get(self._controller_uid)
OM = ObjectManager(self)
if uid is None: # Object attributes
return
if uid == controller._PSEUDOROOTUID and tree_tid is None:
return
#
self.popup_obj = (uid, tree_tid)
self.popupmenu = wx.Menu()
if self._is_convertible(uid):
item = self.popupmenu.Append(wx.NewId(), 'Convert unit')
self.Bind(wx.EVT_MENU, self.OnUnitConvert, item)
self.popupmenu.AppendSeparator()
#
if tree_tid is not None:
# Exclude all objects from a class
menu_option_str = u'Exclude all objects [{}]'.format(tree_tid)
else:
# Exclude a specific object
obj = OM.get(uid)
#classid, oid = uid
menu_option_str = u'Exclude object ['
menu_option_str = menu_option_str + str(obj.name) + u']'
#
item = self.popupmenu.Append(wx.NewId(), menu_option_str)
self.Bind(wx.EVT_MENU, self.OnPopupItemSelected, item)
#
pos = event.GetPoint()
self.PopupMenu(self.popupmenu, pos)
评论列表
文章目录