# # 1 #!/usr/bin/env python 2 #----------------------------------------------- 3 # Name: Hello.Py 4 # Purpose: The obligatory `hello world' program 5 #----------------------------------------------- 7 ## import all of the wxPython GUI package 8 from wxPython.wx import * 10 ## Create a new frame class, derived from the wxPython Frame. 11 class MyFrame(wxFrame): 12 def __init__(self, parent, id, title): 13 # First, call the base class method to create the frame 14 wxFrame.__init__(self, parent, id, title, 15 wxPoint(100, 100), wxSize(160, 100)) 17 # Add a panel to display the simple `hello' message 18 panel = wxPanel(self, -1) 19 wxStaticText(panel, -1, "Hello world of xwPython!", 20 wxDLG_PNT(panel, wxPoint(4, 20)), wxDefaultSize) 22 # Every wxWindows application must have a class derived from wxApp 23 class MyApp(wxApp): 24 # wxWindows calls this method to initialize the application 25 def OnInit(self): 26 # Create an instance of our customized Frame class 27 frame = MyFrame(NULL, -1, "Hello!") 28 frame.Show(true) 29 # Tell wxWindows that this is our main window 30 self.SetTopWindow(frame) 31 # Return a success flag 32 return true 34 # if running standalone 35 if __name__ == "__main__": 36 app = MyApp(0) # Create an instance of the application class 37 app.MainLoop() # Tell it to start processing events 38 # End of Program