All the examples shown are from wxpython in action. Only my annotations are added.
# ! /Usr/bin/Python # -*-<Coding = UTF-8> -*- """ Hello, wxpython! Program. """ Import WX Class Frame (wx. Frame ): """ Create a subclass of Wx. Frame """ Def _ Init __ (Self, image, parent = none, id =-1, Pos = wx. defaultposition, Title = " Hello, wxpython! " ): """ In _ init _, which parameters are required? Who can remember each time there are so many parameters. however, parameters do not have order requirements. think about what is required to create a frame, such as position, size, title, and ID. """ # Convert to BMP for easy processing Temp = Image. converttobitmap () # Obtains the image size and uses it as the frame size. Size =Temp. getwidth (), temp. getheight () WX. Frame. _ Init __ (Self, parent, ID, title, POs, size) # You can see staticbitmap (parent = self), where self points to frame, so the image is displayed on the frame. # If you want to modify the parent if you want to create a panel in the frame, try it. # Note the difference between the two sentences because the parent parameters are different. After running, you can see that if you draw a picture on the frame, it will be covered by the Panel. # If you draw a picture on a panel, there will be no problems, or you will not create a panel, or draw a picture on a frame. To some extent, you can understand some of the meanings of self. Panel = wx. Panel (self,-1 ) WX. staticbitmap (parent = Self, bitmap = Temp) WX. staticbitmap (parent = Panel, bitmap = Temp) Class APP (wx. app ): Def Oninit (Self): Image = Wx. Image ( " Filezilla.png " , Wx. bitmap_type_png) self. Frame = Frame (image) self. Frame. Show () self. settopwindow (self. Frame) Return True Def Main (): app = APP () app. mainloop () If _ Name __ = " _ Main __ " : Main ()