The #!/usr/bin/python#-*-<coding=utf-8>-*-"" "Wxpython program is made up of two necessary objects: the Application object, which is WX. The app or its sub-class object; The top-Level window object, which is WX. Frame or its subclass object; Create a WX. Subclass of the app, you need to perform four steps: 1. Define this subclass; 2. Write a OnInit () method in the defined subclass 3. Create an instance of this subclass in your program; 4. Invoke the Mainloop () method of the application instance, which gives control of the program to Wxpython "" "Import Wxclass MyApp (WX. APP): #这是第一步, the WX is defined. Sub-category of the app; #编写OnInit () method def OnInit (self): "" creates a top-level window object in an Application object; Call the Show method of the top-level window object to make it appear. "" " frame = wx. Frame (id=-1,parent=none,pos=wx. Defaultposition,size=wx. DefaultSize) frame. The Show () #OnInit () method must return a bool value. Return true# step three, Instantiate Myappapp = MYAPP () #第四步, call Mainloop method App.mainloop ()
How to create and use Wxapp application objects