On init and on exit : Frame « wxPython « Python Tutorial






On init and on exit
import wx
import sys

class Frame(wx.Frame):
    def __init__(self, parent, id, title):
        print "Frame __init__"
        wx.Frame.__init__(self, parent, id, title)

class App(wx.App):
    def __init__(self, redirect=True, filename=None):
        print "App __init__"
        wx.App.__init__(self, redirect, filename)

    def OnInit(self):
        print "OnInit"
        self.frame = Frame(parent=None, id=-1, title='Startup')
        self.frame.Show()
        self.SetTopWindow(self.frame)
        print "A pretend error message"
        print self.GetVendorName()
        return True

    def OnExit(self):
        print "OnExit"

app = App(redirect=True)
print "before MainLoop"
fred = app.MainLoop()
print "after MainLoop", fred








19.15.Frame
19.15.1.Set the size of windowSet the size of window
19.15.2.Default frame styleDefault frame style
19.15.3.Creating and Showing a FrameCreating and Showing a Frame
19.15.4.Display a frameDisplay a frame
19.15.5.Set top windowSet top window
19.15.6.Frame that displays an image.
19.15.7.Adding Labels and Titles with Keyword ArgumentsAdding Labels and Titles with Keyword Arguments
19.15.8.Frame with events: on close, on close windowFrame with events: on close, on close window
19.15.9.On init and on exitOn init and on exit
19.15.10.Bind key event and button eventBind key event and button event
19.15.11.Set frame propertiesSet frame properties
19.15.12.Add contro to frame and layout themAdd contro to frame and layout them
19.15.13.Subclass frameSubclass frame
19.15.14.Help ContextHelp Context