Menubutton widget that leads to a cascade
of submenus. When the user reaches an actual text item,
that item appears in a pop-up
# - - - 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.
Selecting a standard color: Section 12.3, “
Adjusting colors: Section 12.6, “
Selecting background or text color: Section 12.7, “
Color models and color space: Section 12.8, “
The HSV color model: Section 12.9, “
The RGB color model: Section 12.10, “
The CMY color model: Section 12.11, “
Using the color sliders: Section 12.12, “
Viewing colors and fonts: Section 12.13, “
Importing colors into other applications: Section 12.19, “
Who made this tool? Section 12.20, “
First we create the two interlinked widgets that make up a
drop-down menu: the
Menubutton, which appears all
the time as the button, and the
Menu widget, which contains the cascades that
appear when the user clicks the
#-- 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
parent of the
Menu. The downward linkage
is established by setting the
menu attribute to the
#-- 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
A cascade is a choice that leads to another level of drop-down menu. This type of choice is identified by a right-pointing arrowhead.
Terminal (non-cascade) choices are identified by a simple text label without a right-pointing arrowhead.
#-- 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?" )
Menubutton is returned to the
caller for gridding.
#-- 8 -- return mb