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

18. class ColorSliders: Color model parameter sliders

This class is a compound widget containing three sliders (Tkinter Scale widgets) that the user can drag to change the value of one of the color model's parameters.

# - - - - -   c l a s s   C o l o r S l i d e r s

class ColorSliders(Frame):
    """Compound widget for displaying and adjusting color parameters

        ColorSliders ( parent, color, callback=None ):
          [ (parent is a Frame) and
            (color is the initial color as a Color instance) and
            (callback is a function or None) ->
              parent  :=  parent with a new ColorSliders widget
                  added but not gridded, using the HSV model,
                  initially displaying white, that will call
                  callback(color) whenever the user changes a
                  color parameter
              return that new ColorSliders widget ]

The .setModel() changes the model used to compute the slider positions; see Section 18.1, “ColorSliders.setModel(): Display a new color model”.

        .setModel ( model ):
          [ model is a concrete subclass of ColorModel ->
              self  :=  self with its current color displayed
                        using model ]

The .setColor() method changes the currently displayed color; see Section 18.2, “ColorSliders.setColor(): Change the displayed color”.

        .setColor ( color ):
          [ color is a Color instance ->
              self  :=  self displaying color using its current
                        model ]

The label for this widget spans all the columns in row 0. The three ParamSlider widgets are gridded horizontally across row 1.

      Internal widgets:
        .__topLabel:    [ a Label that describes this widget ]
          [ a list containing three ParamSlider widgets
            corresponding to the three parameters of self.__model
            in the same order ]

      Grid plan:
           0                  1                  2
        0 | .__topLabel                                            |
        1 | .__sliderList[0] | .__sliderList[1] | .__sliderList[2] |

Internal state includes the current color and the current color model.

        .__callback:  [ as passed to the constructor ]
        .__color:     [ the currently displayed color as a Color ]
          [ the current color model as a concrete subclass of
            ColorModel ]