wxPython入门hello world
import wx
class ButtonFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, '窗口标题', size=(300, 200))
panel = wx.Panel(self, -1)
self.btnOk = wx.Button(panel, 1, "OK", pos=(50, 50))
self.btnCancel = wx.Button(panel, 2, "Cancel", pos=(150, 50))
self.Bind(wx.EVT_BUTTON, self.OnOk, self.btnOk)
self.Bind(wx.EVT_BUTTON, self.OnCancel, self.btnCancel)
self.btnOk.SetDefault()
self.btnCancel.SetDefault()
def OnOk(self, event):
wx.MessageBox("OK","button标题")
def OnCancel(self, event):
wx.MessageBox("Cancel")
self.Close(True)
if __name__ == '__main__':
app = wx.PySimpleApp()
frame = ButtonFrame()
frame.Show()
app.MainLoop()