Next / Previous / Contents / Shipman's 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.

# - - -   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().

        #-- 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.

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