Next / Previous / Contents / TCC Help System / NM Tech homepage

5. main(): The main program

The graphical user interface as a whole is represented by the Application class. Calling the constructor initializes the application. See Section 11, “class Application: The outermost frame”.

huey
# - - - - -   m a i n

def main():
    """Main program.

      [ display a graphical application that allows the user to
        test various fonts in various colors displayed on various
        background colors ]
    """

    #-- 1 --
    # [ the screen  :=  the screen with a graphical application
    #   app  :=  the graphical application ]
    app  =  Application()

Before actually running the application, we need to place the title of the application in the top-level window. This title will be displayed in the decorations applied by the user's window manager. The .winfo_toplevel() method returns the top-level window of the application; the .title() method sets the title in that window. If we don't do this, the default window title will be just “tk”.

huey
    #-- 2 --
    # [ app  :=  app with its window title set to the name of
    #            this application ]
    app.winfo_toplevel().title( "%s %s" %
                                (PROGRAM_NAME,  EXTERNAL_VERSION) )

The .mainloop() method starts the application running. It will respond to events until the user terminates it by clicking the Quit button.

huey
    #-- 3 --
    # [ app  :=  app responding to user events ]
    app.mainloop()