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

16.2. ColorReadout.set(): Change the displayed color

When the user changes the current color, either by clicking on it in the color name pick list, or by adjusting one of the color parameter sliders, this method is called to display the new color's name.

huey
# - - -   C o l o r R e a d o u t . s e t

    def set ( self, color ):
        """Change the currently selected color.
        """

Translating a color into "#RRGGBB" is done by the Color.__str__() method. The widgets that display this string are linked to control variables, so a call to the control variable's .set() method changes the displayed label. See Section 16.3, “ColorReadout.internalSet().

huey
        #-- 1 --
        # [ if self.isText() ->
        #     self's text color  :=  color
        #   else ->
        #     self's background color  :=  color ]
        self.internalSet ( color )

External observers must also be notified that the current color has changed.

huey
        #-- 2 --
        if  self.__callback is not None:
            self.__callback ( )