This method creates and grids all the widgets for the
Application class.
# - - - A p p l i c a t i o n . _ _ c r e a t e W i d g e t s
def __createWidgets ( self ):
"""Create and grid all widgets.
"""
The MenuBar compound widget occupies the
full width of row 0. The sticky parameter
makes it adhere to the left (west) side of its grid cell.
See Section 12, “class MenuBar: General controls”.
#-- 1 --
# [ self := self with a new MenuBar widget added
# self.__menuBar := that widget ]
self.__menuBar = MenuBar ( self )
self.__menuBar.grid ( row=0, column=0, columnspan=3,
sticky=W )
Next we add the NamePicker widget. The
first argument to a widget constructor is always the
parent widget, self in this case. The
second argument is a callback function that is called
whenever the user selects a color. See Section 13, “class NamePicker: Select colors by name”.
#-- 2 --
# [ self := self with a new NamePicker widget added that
# calls self.__nameHandler when a name is picked
# self.__namePicker := that NamePicker ]
self.__namePicker = NamePicker ( self, self.__nameHandler )
self.__namePicker.grid ( row=1, column=0, sticky=NW )
The Adjuster widget constructor also gets
a second argument containing the name of a callback
function, which will be called whenever the user adjusts
the current color. See Section 15, “class Adjuster: Color adjustment and
color model selection”.
#-- 3 --
# [ self := self with a new Adjuster widget added that calls
# self.__adjustHandler when the color is adjusted
# self.__adjuster := that Adjuster widget
self.__adjuster = Adjuster ( self, self.__adjustHandler )
self.__adjuster.grid ( row=1, column=1, sticky=N, padx=4 )
Last to go in is the Swatch widget; see
Section 20, “class Swatch: Font and color samples”.
#-- 4 --
# [ self := self with a new Swatch widget added, using
# the background and text colors from self.__adjuster
# self.__swatch := that widget ]
self.__swatch = Swatch ( self, self.__adjuster.bgColor(),
self.__adjuster.textColor() )
self.__swatch.grid ( row=1, column=2, sticky=N )