def show_context_menu(self, item, mouse_pos=None):
if item:<EOL><INDENT>d = self.tree.GetItemData(item)<EOL>if d:<EOL><INDENT>obj = d.GetData()<EOL>if obj:<EOL><INDENT>self.highlight(obj.wx_obj)<EOL>self.obj = obj<EOL>menu = wx.Menu()<EOL>id_del, id_dup, id_raise, id_lower = [wx.NewId() for i<EOL>in range(<NUM_LIT:4>)]<EOL>menu.Append(id_del, "<STR_LIT>")<EOL>menu.Append(id_dup, "<STR_LIT>")<EOL>menu.Append(id_raise, "<STR_LIT>")<EOL>menu.Append(id_lower, "<STR_LIT>")<EOL>sm = wx.Menu()<EOL>for ctrl in sorted(obj._meta.valid_children,<EOL>key=lambda c: <EOL>registry.ALL.index(c._meta.name)):<EOL><INDENT>new_id = wx.NewId()<EOL>sm.Append(new_id, ctrl._meta.name)<EOL>self.Bind(wx.EVT_MENU, <EOL>lambda evt, ctrl=ctrl: self.add_child(ctrl, mouse_pos), <EOL>id=new_id)<EOL><DEDENT>menu.AppendMenu(wx.NewId(), "<STR_LIT>", sm)<EOL>self.Bind(wx.EVT_MENU, self.delete, id=id_del)<EOL>self.Bind(wx.EVT_MENU, self.duplicate, id=id_dup)<EOL>self.Bind(wx.EVT_MENU, self.bring_to_front, id=id_raise)<EOL>self.Bind(wx.EVT_MENU, self.send_to_back, id=id_lower)<EOL>self.PopupMenu(menu)<EOL>menu.Destroy()<EOL>self.load_object(self.root_obj)<EOL><DEDENT><DEDENT><DEDENT>
Open a popup menu with options regarding the selected object