splitter.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from typing import Callable, Optional, Tuple
  2. from .mixins.disableable_element import DisableableElement
  3. from .mixins.value_element import ValueElement
  4. class Splitter(ValueElement, DisableableElement):
  5. def __init__(self, *,
  6. horizontal: Optional[bool] = False,
  7. reverse: Optional[bool] = False,
  8. limits: Optional[Tuple[float, float]] = (0, 100),
  9. value: Optional[float] = 50,
  10. on_change: Optional[Callable] = None) -> None:
  11. """Splitter
  12. The `ui.splitter` element divides the screen space into resizable sections,
  13. allowing for flexible and responsive layouts in your application.
  14. Based on Quasar's Splitter component:
  15. `Splitter <https://quasar.dev/vue-components/splitter>`_
  16. It provides three customizable slots, ``before``, ``after``, and ``separator``,
  17. which can be used to embed other elements within the splitter.
  18. :param horizontal: Whether to split horizontally instead of vertically
  19. :param limits: Two numbers representing the minimum and maximum split size of the two panels
  20. :param value: Size of the first panel (or second if using reverse)
  21. :param reverse: Whether to apply the model size to the second panel instead of the first
  22. :param on_change: callback which is invoked when the user releases the splitter
  23. """
  24. super().__init__(tag='q-splitter', value=value, on_value_change=on_change, throttle=0.05)
  25. self._props['horizontal'] = horizontal
  26. self._props['limits'] = limits
  27. self._props['reverse'] = reverse
  28. self.before = self.add_slot('before')
  29. self.after = self.add_slot('after')
  30. self.separator = self.add_slot('separator')