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

19.5. ParamSlider.__createWidgets()

huey
# - - -   P a r a m S l i d e r . _ _ c r e a t e W i d g e t s

    def __createWidgets ( self ):
        """Create and grid all widgets.
        """

The first widget is the Label that displays the parameter name.

huey
        #-- 1 --
        # [ self  :=  self with a new Label added and gridded,
        #             with control variable self.__topLabelVar
        #   self.topLabel  :=  that new Label ]
        self.__topLabel  =  Label ( self, font=BUTTON_FONT,
            textvariable=self.__topLabelVar )
        rowx  =  0
        self.__topLabel.grid ( row=rowx, column=0 )

Next is a button with “+” on it that increments the parameter value by 256, which is equivalent to an increment of 1 in the Scale widget's control variable. For the associated handler, see Section 19.6, “ParamSlider.__plusHandler(): Increment the parameter”.

huey
        #-- 2 --
        # [ self  :=  self with a new Button widget added and gridded
        #       that adds 1 to self.__scaleVar but no higher than
        #       MAX_BYTE
        #   self.__plusButton  :=  that widget ]
        self.__plusButton  =  Button ( self, font=BUTTON_FONT,
            text="+", command=self.__plusHandler )
        rowx  +=  1
        self.__plusButton.grid ( row=rowx, column=0 )

The Scale widget comes next. Its handler, called when the user drags the slider, is Section 19.8, “ParamSlider.__scaleHandler(): Somebody dragged the scale”.

huey
        #-- 3 --
        # [ self  :=  self with a new Scale widget added and gridded,
        #       with control variable self.__scaleVar, and a length
        #       of (MAX_BYTE+1) pixels
        #   self.__scale  :=  that Scale widget ]
        self.__scale  =  Scale ( self, orient=VERTICAL,
            command=self.__scaleHandler,
            length=(MAX_BYTE+1), from_=MAX_BYTE, to=0,
            variable=self.__scaleVar )
        rowx  +=  1
        self.__scale.grid ( row=rowx, column=0 )

The “-” button is pretty similar to the “+” button. For its handler, see Section 19.7, “ParamSlider.__minusHandler(): Decrement the parameter”.

huey
        #-- 4 --
        # [ self  :=  self with a new Button widget added and gridded
        #       that subtracts 1 to self.__scaleVar but no lower than 0
        #   self.__minusButton  :=  that widget ]
        self.__minusButton  =  Button ( self, font=BUTTON_FONT,
            text="-", command=self.__minusHandler )
        rowx  +=  1
        self.__minusButton.grid ( row=rowx, column=0 )