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

12.2. MenuBar.__createHelp(): Create the Help menu

The visible Help button is a Menubutton widget that leads to a cascade of submenus. When the user reaches an actual text item, that item appears in a pop-up Dialog.

huey
# - - -   M e n u B a r . _ _ c r e a t e H e l p

    def __createHelp ( self ):
        """Create the help menubutton and its cascade.

          [ self is a Frame ->
              self  :=  self with a new Menubutton added but not
                        gridded, leading to the help text
              return that new Menubutton ]
        """

Here is an outline showing the structure of the help cascade, with links to the methods that set them up.

First we create the two interlinked widgets that make up a drop-down menu: the Menubutton, which appears all the time as the Help button, and the Menu widget, which contains the cascades that appear when the user clicks the Menubutton.

huey
        #-- 1 --
        # [ mb  :=  a new Menubutton with self as its parent ]
        mb  =  Menubutton ( self, font=BUTTON_FONT,
                            relief=RAISED,
                            text="Help" )

Creating the mutual linkage between the Menubutton and its first-level Menu is not completely obvious. The upward linkage is established by making the Menubutton the parent of the Menu. The downward linkage is established by setting the Menu's menu attribute to the Menubutton.

huey
        #-- 2 --
        # [ menu  :=  a new Menu with mb as its parent
        #   mb    :=  mb with its 'menu' attribute set to that
        #             new Menu ]
        menu  =  Menu ( mb )
        mb['menu']  =  menu

There are two kinds of choices on a drop-down Menu:

huey
        #-- 3 --
        # [ menu  :=  menu with a cascade added about selecting
        #             colors by name ]
        self.__cascadeNamePicker ( menu )

        #-- 4 --
        # [ menu  :=  menu with a cascade added about adjusting
        #             colors ]
        self.__cascadeAdjuster ( menu )

        #-- 5 --
        # [ menu  :=  menu with a cascade added about viewing colors ]
        self.__cascadeViewing ( menu )

        #-- 6 --
        # [ menu  :=  menu with a pop-up added about importing
        #             colors into other applications
        menu.add_command ( command=self.__helpImporting,
            label="Importing colors into other applications" )

        #-- 7 --
        # [ menu  :=  menu with a pop-up added about the author ]
        menu.add_command ( command=self.__helpAuthor,
            label="Who made this tool?" )

The finished Menubutton is returned to the caller for gridding.

huey
        #-- 8 --
        return mb