First page Back Continue Last page Overview Graphics

WxPython Quickie

  • from wxPython.wx import *
  • class DerivedApp(wxApp):
  • “””Must specialize the wxPython.wx.wxApp class”””
  • def OnInit(self):
  • frame = wxFrame(NULL, -1, "Hello wxPython!")
  • buttonId = wxNewId() button = wxButton(frame, buttonId, “Push Me”)
  • EVT_BUTTON(self, buttonId, self.buttonPushed)
  • frame.Show(true)
  • self.SetTopWindow(frame)
  • return true # return false to exit application
  • def buttonPushed(self, *unused): print ‘Who pushed my button?’
  • app = DerivedApp(0) # create our wxApp
  • app.MainLoop() # start the main event loop

    Notes: