Next / Previous / Contents / Shipman's homepage

11.1. Application.__init__(): Constructor

The constructor creates the application window and populates it with its four contained widgets.

# - - -   A p p l i c a t i o n . _ _ i n i t _ _

    def __init__ ( self ):
        """Constructor for Application.

Because this class inherits from Frame, the first order of business is to call the parent class's constructor. The first argument is self, the new instance's namespace. The second argument is the parent window; passing None has the effect of creating a new root window.

Calling the .grid() method on self is necessary to register the new window; if this isn't done, the application will not appear on the screen.

        #-- 1 --
        # [ self  :=  self as a new root window Frame ]
        Frame.__init__ ( self, None )

Widget creation is handled by Section 11.2, “Application.__createWidgets(): Set up the widgets”.

        #-- 2 --
        # [ self  :=  self with all widgets created and gridded ]