Q:

wxpython menu callback stackoverflow

def menuclick(e):
    print(menu.FindItemById(e.Id).Label)
0
import wx

app = wx.App(False)
frame = wx.Frame(None)

menuBar = wx.MenuBar()
menu = wx.Menu()
menuBar.Append(menu, "&Menu")
frame.SetMenuBar(menuBar)

for name in ['foo','bar','baz']:
    menuitem = menu.Append(-1,"&"+name,name)
    def menuclick(e):
        print(name)
    frame.Bind(wx.EVT_MENU, menuclick, menuitem)

frame.Show(True)
app.MainLoop()
1

New to Communities?

Join the community