Saturday 31 August 2013

Bind multiple wx.EVT_MENU to a same method?

Bind multiple wx.EVT_MENU to a same method?

There're about 5-6 menu items in the right click popup, and binding them
to separate methods seems clumsy since there's a good chunk of codes can
be reused, is it possible to do things like this?
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.
I noticed there's no GetMenu() available for wx.EVT_MENU, so basically how
do you recognize which menu is being clicked?

No comments:

Post a Comment