slider.py 817 B

12345678910111213141516171819202122232425
  1. from typing import Callable
  2. import justpy as jp
  3. from .float_element import FloatElement
  4. class Slider(FloatElement):
  5. def __init__(self,
  6. *,
  7. min: float,
  8. max: float,
  9. step: float = 1,
  10. value: float = None,
  11. on_change: Callable = None,
  12. ):
  13. """Slider Element
  14. :param min: lower bound of the slider
  15. :param max: upper bound of the slider
  16. :param step: step size
  17. :param value: inital value to set position of the slider
  18. :param on_change: callback which is invoked when the user releases the slider
  19. """
  20. view = jp.QSlider(min=min, max=max, step=step, change=self.handle_change)
  21. super().__init__(view, value=value, on_change=on_change)