every wxpython application must have single wx app instance the creation of all of the ui objects should be delayed until after the wx app object has been created in order to ensure that the gui platform and wxwidgets have been fully initialised it is common to subclass the wx app class and override methods such as onpreinit and onexit to provide custom behaviour this ensures that the required behaviour is run at appropriate times the methods that can be overridden for this purpose areonpreinitthis method can be overridden to define behaviour that should be run once the application object is createdbut before the oninit method has been called oninit this is expected to create the applications main windowdisplay that window etc onrunthis is the method used to start the execution of the main program onexitthis can be overridden to provide any behaviour that should be called just before the application exits as an exampleif we wish to set up gui application such that the main frame is initialised and shown after the wx app has been instantiated then the safest way is to override the oninit(method of the wx app class in suitable subclass the method should return true of falsewhere true is used to indicate that processing of the application should continue and false indicates that the application should terminate immediately (usually as the result of some unexpected issuean example wx app subclass is shown belowclass mainapp(wx app)def oninit(self)""initialise the main gui application""frame welcomeframe(frame show(indicate whether processing should continue or not return true this class can now be instantiated and the mainloop startedfor examplerun the gui application app mainapp(app mainloop(it is also possible to override the onexit(to clean up anything initialised in the oninit(method