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

20.5. Swatch.__createWidgets()

For the widget layout, see Section 20, “class Swatch: Font and color samples”.

huey
# - - -   S w a t c h . _ _ c r e a t e W i d g e t s

    def __createWidgets ( self ):
        """Create and grid all internal widgets.
        """

First comes the Text widget. The wrap=NONE operation causes the text to be cropped if it won't fit in the window.

huey
        #-- 1 --
        # [ self  :=  self with a new Text widget added
        #   self.__text  :=  that widget ]
        self.__text  =  Text ( self,
            bg=self.__bgColor, fg=self.__textColor,
            width=self.SWATCH_WIDE,
            height=self.SWATCH_HIGH )
        rowx  =  0
        self.__text.grid ( row=rowx, column=0, sticky=W )

Next is the FontSelect widget. For the documentation on this widget, see Section 4.1, “Imports”. Its callback, Section 20.6, “Swatch.__fontHandler(): Handle a font change”, is called whenever the user changes the font in any way.

huey
        #-- 2 --
        # [ self  :=  self with a new FontSelect widget added that
        #       calls self.__fontHandler when the font is changed
        #   self.__fontSelect  :=  that widget ]
        self.__fontSelect  =  FontSelect ( self,
            font=BUTTON_FONT,
            listCount=self.FONT_FAMILIES,
            observer=self.__fontHandler )
        rowx  +=  1
        self.__fontSelect.grid ( row=rowx, column=0, sticky=W )