wxpython menu callback stackoverflow

Solutions on MaxInterview for wxpython menu callback stackoverflow by the best coders in the world

showing results for - "wxpython menu callback stackoverflow"
Albin
23 Jan 2019
1import wx
2
3app = wx.App(False)
4frame = wx.Frame(None)
5
6menuBar = wx.MenuBar()
7menu = wx.Menu()
8menuBar.Append(menu, "&Menu")
9frame.SetMenuBar(menuBar)
10
11for name in ['foo','bar','baz']:
12    menuitem = menu.Append(-1,"&"+name,name)
13    def menuclick(e):
14        print(name)
15    frame.Bind(wx.EVT_MENU, menuclick, menuitem)
16
17frame.Show(True)
18app.MainLoop()
19
Juan Diego
23 Apr 2017
1def menuclick(e):
2    print(menu.FindItemById(e.Id).Label)
3
similar questions
queries leading to this page
wxpython menu callback stackoverflow