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

20.4. Swatch.__init__(): Constructor

Call the parent constructor, then create the widgets; see Section 20.5, “Swatch.__createWidgets().

huey
# - - -   S w a t c h . _ _ i n i t _ _

    def __init__ ( self, parent, bg, fg ):
        """Constructor for Swatch.
        """
        #-- 1 --
        # [ parent  :=  parent with a new Frame added
        #   self  :=  that Frame ]
        Frame.__init__ ( self, parent )

        #-- 2 --
        self.__textColor  =  fg
        self.__bgColor  =  bg

        #-- 3 --
        # [ self  :=  self with all internal widgets added and gridded ]
        self.__createWidgets()

At this point the FontSelect widget contains an initial font, so we can set up the Text widget to use that font. Then we place some sample text into the Text widget.

huey
        #-- 4 --
        # [ self.__text  :=  self.__text using the font from
        #                    self.__fontSelect ]
        self.__text["font"]  =  self.__fontSelect.get()

        #-- 5 --
        # [ self.__text  :=  self.__text with some sample text added ]
        self.__text.insert ( END, self.SWATCH_TEXT )