右键弹出菜单中大约有 5-6 个菜单项,将它们绑定到单独的方法似乎很笨拙,因为有很多代码可以重用,是否可以做这样的事情?
self.Bind(wx.EVT_MENU, self.MenuClicked, id=self.menu1)
self.Bind(wx.EVT_MENU, self.MenuClicked, id=self.menu2)
self.Bind(wx.EVT_MENU, self.MenuClicked, id=self.menu3)
self.Bind(wx.EVT_MENU, self.MenuClicked, id=self.menu4)
self.Bind(wx.EVT_MENU, self.MenuClicked, id=self.menu5)
def MenuClicked(self, event):
detect which menu being clicked
assign specific values to several variables regarding the menu being clicked
rest of the codes.
我注意到没有GetMenu()
可用的wx.EVT_MENU
,所以基本上你如何识别正在单击哪个菜单?