def update_value(self):
        """Update value attribute using handle position."""
        ### retrieve handle x center pos
        handle_centerx = self.handle.rect.centerx

        ### retrieve selection area starting x and width

        x = self.selection_area.x
        width = self.selection_area.width

        ### calculate value based on
        ### - proportion of the handle distance from x
        ###   to the width of selection area
        ### - maximum possible value

        distance = handle_centerx - x
        percentage = distance / width

        self.value = round(percentage * self.max_value)
Update value attribute using handle position.
nodezator/our3rdlibs/scale.py