フォームにメニュをつける
2009/11/5
wxPython2.8.9.2
import wx
def main():
app = wx.App()
frame = wx.Frame(parent=None)
menu = wx.Menu()
menu.Append(1, "Open")
menu.Append(2, "Save")
menu.Append(3, "Exit")
menuBar = wx.MenuBar()
menuBar.Append(menu, "File")
frame.SetMenuBar(menuBar)
frame.Bind(wx.EVT_MENU, menu_open, id=1)
frame.Bind(wx.EVT_MENU, menu_save, id=2)
frame.Bind(wx.EVT_MENU, menu_exit, id=3)
frame.Show()
app.MainLoop()
def menu_open(event):
print("press menu open!")
def menu_save(event):
print("press menu save!")
def menu_exit(event):
print("press menu exit!")
if __name__ == '__main__':
main()