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

15.8. Adjuster.__readoutHandler(): Change between text and background colors

This method is called by the ColorReadout widget when the user changes between displaying the text color and displaying the background color. It has two functions:

  1. Internally, it tells the ColorSliders to display whichever color is now shown in the ColorReadout widget.

  2. Externally, it calls the Adjuster instance's callback function.

huey
# - - -   A d j u s t e r . _ _ r e a d o u t H a n d l e r

    def __readoutHandler ( self ):
        """Change the internal and external colors.

          [ if  self.isText() ->
              self  :=  self displaying the text color
              call self.__callback(True, self.textColor())
            else ->
              self  :=  self displaying the background color
              call self.__callback(False, self.bgColor()) ]
        """

The first step is to determine which color the sliders display: the text color or the background color. Then order the ColorSliders widget to display that color using the current color model.

huey
        #-- 1 --
        if self.isText():
            sliderColor  =  self.textColor()
        else:
            sliderColor  =  self.bgColor()

        #-- 2 --
        # [ self.__colorSliders  :=  self.__colorSliders displaying
        #                            sliderColor ]
        self.__colorSliders.setColor ( sliderColor )

We must also notify self's callback.

huey
        #-- 3 --
        if  self.__callback is not None:
            self.__callback ( self.isText(), sliderColor )