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

12.1. MenuBar.__init__(): Constructor

The constructor starts by calling its parent class's constructor, which makes it a proper Frame widget. It is not gridded in the parent; that is the caller's job. Then the contained widgets are created and gridded within self.

huey
# - - -   M e n u B a r . _ _ i n i t _ _

    def __init__ ( self, parent ):
        """Constructor for MenuBar"""
        #-- 1 --
        # [ self  :=  self as a Frame, ungridded ]
        Frame.__init__ ( self, parent )

The Help button is a menubutton, but there are many submenus. This whole drop-down menu structure is built by Section 12.2, “MenuBar.__createHelp(): Create the Help menu”.

huey
        #-- 2 --
        # [ self  :=  self with a new Menubutton added and
        #       gridded, leading to the help menu cascades ]
        self.__helpButton  =  self.__createHelp()
        self.__helpButton.grid ( row=0, column=0 )

The Quit button is linked to the .quit() method that exists on all Tkinter widgets.

huey
        #-- 3 --
        # [ self  :=  self with a Quit button added and gridded
        #             that terminates execution ]
        self.__quitButton  =  Button ( self, text='Quit',
            font=BUTTON_FONT, command=self.quit )
        self.__quitButton.grid ( row=0, column=1 )