The visible 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.
# - - - 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, “MenuBar.__cascadeNamePicker()”.
Typing in a standard color name: Section 12.4, “MenuBar.__helpTyping()”.
Picking a standard color name: Section 12.5, “MenuBar.__helpPicking()”.
Adjusting colors: Section 12.6, “MenuBar.__cascadeAdjuster()”.
Selecting background or text color: Section 12.7, “MenuBar.__helpReadout()”.
Color models and color space: Section 12.8, “MenuBar.__helpModelSelector()”.
The HSV color model: Section 12.9, “MenuBar.__helpHSV()”.
The RGB color model: Section 12.10, “MenuBar.__helpRGB()”.
The CMY color model: Section 12.11, “MenuBar.__helpCMY()”.
Using the color sliders: Section 12.12, “MenuBar.__helpSliders()”.
Viewing colors and fonts: Section 12.13, “MenuBar.__cascadeViewing()”.
The color swatch: Section 12.14, “MenuBar.__helpSwatch()”.
Selecting a font: Section 12.15, “MenuBar.__cascadeFonts()”.
Selecting a font family: Section 12.16, “MenuBar.__helpFontFamily()”.
Changing the font size: Section 12.17, “MenuBar.__helpFontSize()”.
Changing font weight and slant: Section 12.18, “MenuBar.__helpFontStyle()”.
Importing colors into other applications: Section 12.19, “MenuBar.__helpImporting()”.
Who made this tool? Section 12.20, “MenuBar.__helpAuthor()”.
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 Menubutton.
#-- 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.
#-- 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:
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?" )
The finished Menubutton is returned to the
caller for gridding.
#-- 8 --
return mb