slider.py 931 B

1234567891011121314151617181920212223242526
  1. from typing import 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] = None) -> None:
  11. """Slider
  12. :param min: lower bound of the slider
  13. :param max: upper bound of the slider
  14. :param step: step size
  15. :param value: initial value to set position of the slider
  16. :param on_change: callback which is invoked when the user releases the slider
  17. """
  18. super().__init__(tag='q-slider', value=value, on_value_change=on_change, throttle=0.05)
  19. self._props['min'] = min
  20. self._props['max'] = max
  21. self._props['step'] = step