37,719
社区成员
发帖
与我相关
我的任务
分享
import wx
class App(wx.App):
def OnInit(self):
frame = MainFrame()
frame.Show()
self.SetTopWindow(frame)
return True
class MainFrame(wx.Frame):
title = "Main Frame"
def __init__(self):
wx.Frame.__init__(self, None, 1, self.title) #id = 5
menuFile = wx.Menu()
menuAbout = wx.Menu()
menuAbout.Append(2, "&About...", "About this program")
menuBar = wx.MenuBar()
menuBar.Append(menuAbout, "&Help")
self.SetMenuBar(menuBar)
self.CreateStatusBar()
self.Bind(wx.EVT_MENU, self.OnAbout, id=2)
def OnQuit(self, event):
self.Close()
def OnAbout(self, event):
AboutFrame().Show()
class AboutFrame(wx.Frame):
title = "About"
def __init__(self):
wx.Frame.__init__(self, wx.GetApp().TopWindow, title=self.title)
vsizer1 = wx.BoxSizer(orient=wx.VERTICAL)
wbtn2 = wx.Button(self, -1, 'Button')
vsizer1.Add(wbtn2, 0, wx.ALIGN_CENTER | wx.ALL, 5)
self.SetSizer(vsizer1)
if __name__ == '__main__':
app = App(False)
app.MainLoop()