slider.py 965 B

123456789101112131415161718192021222324252627
  1. from typing import Any, Callable, Optional
  2. from .mixins.disableable_element import DisableableElement
  3. from .mixins.value_element import ValueElement
  4. class Slider(ValueElement, DisableableElement):
  5. def __init__(self, *,
  6. min: float,
  7. max: float,
  8. step: float = 1.0,
  9. value: Optional[float] = None,
  10. on_change: Optional[Callable[..., Any]] = None,
  11. ) -> None:
  12. """Slider
  13. :param min: lower bound of the slider
  14. :param max: upper bound of the slider
  15. :param step: step size
  16. :param value: initial value to set position of the slider
  17. :param on_change: callback which is invoked when the user releases the slider
  18. """
  19. super().__init__(tag='q-slider', value=value, on_value_change=on_change, throttle=0.05)
  20. self._props['min'] = min
  21. self._props['max'] = max
  22. self._props['step'] = step