Before I start, if you guys happen to know the creator of wxPython please do ask him this question: Why are you using the term wxPython instead of WxPython? I just feel curious about that!
Alright, after a few articles about Tkinter it is time to write the first wxPython tutorial and in this simple tutorial I am going to create a child class object from wxPython class where this object will be used later in all the tutorial articles about wxPython.
And here is how to create the child class of wxPython.
import wx class DerivedApp(wx.App): def OnInit(self): the_frame = wx.Frame(None, -1) # create the top-level window the_frame.Show(True) return True
According to the wxPython website:-
OnInit will usually create a top window as a bare minimum. Unlike in earlier versions of wxPython, OnInit does not return a frame. Instead, it returns a boolean value that indicates whether processing should continue (True) or not (False).
I personally think that OnInit will get called after the user has created the child class object as shown in the below two lines of code!
wxapp = DerivedApp() # create the child class object wxapp.MainLoop() # this loop will continue running until you close the top-level window
After the program has entered the main loop the top-level window will appear on the screen!
Phew, although it is simple, trust me, this is the method I use to learn Python programming language one bit at a time!