def _create_selected_obj_menus(self, menu):
self._ids_functions = {}
selected_obj_menus = OrderedDict()
UIM = UIManager()
tocs = UIM.list('track_object_controller', self._controller_uid)
for toc in tocs:
if toc.model.selected:
obj = toc.get_object()
if obj:
obj_submenu = wx.Menu()
#
funcs = FunctionManager.functions_available_for_class(obj.__class__)
for f in funcs:
#print
#print f['name']
#print f['friendly_name']
#print f['function']
#print f['args']
#print f['kwargs']
id_ = wx.NewId()
obj_submenu.Append(id_, f['friendly_name'])
self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_)
self._ids_functions[id_] = (f['function'], (obj))
#
obj_submenu.AppendSeparator()
id_ = wx.NewId()
obj_submenu.Append(id_, 'Remove from track')
self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_)
self._ids_functions[id_] = (self._remove_object_helper,
(toc.uid)
)
#
obj_submenu.AppendSeparator()
id_ = wx.NewId()
obj_submenu.Append(id_, 'Delete object')
self.track.Bind(wx.EVT_MENU, self._object_menu_selection, id=id_)
self._ids_functions[id_] = (self._delete_object_helper,
(toc.get_object().uid)
)
#
selected_obj_menus[obj] = obj_submenu
if selected_obj_menus:
for obj, obj_submenu in selected_obj_menus.items():
menu.AppendSubMenu(obj_submenu, obj.get_friendly_name())
menu.AppendSeparator()
评论列表
文章目录