Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

wxpython menu callback stackoverflow

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()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #wxpython #menu #callback #stackoverflow
ADD COMMENT
Topic
Name
4+4 =