splitter.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from typing import Any, 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[..., Any]] = None,
  11. ) -> None:
  12. """Splitter
  13. The `ui.splitter` element divides the screen space into resizable sections,
  14. allowing for flexible and responsive layouts in your application.
  15. Based on Quasar's Splitter component:
  16. `Splitter <https://quasar.dev/vue-components/splitter>`_
  17. It provides three customizable slots, ``before``, ``after``, and ``separator``,
  18. which can be used to embed other elements within the splitter.
  19. :param horizontal: Whether to split horizontally instead of vertically
  20. :param limits: Two numbers representing the minimum and maximum split size of the two panels
  21. :param value: Size of the first panel (or second if using reverse)
  22. :param reverse: Whether to apply the model size to the second panel instead of the first
  23. :param on_change: callback which is invoked when the user releases the splitter
  24. """
  25. super().__init__(tag='q-splitter', value=value, on_value_change=on_change, throttle=0.05)
  26. self._props['horizontal'] = horizontal
  27. self._props['limits'] = limits
  28. self._props['reverse'] = reverse
  29. self._classes = ['nicegui-splitter']
  30. self.before = self.add_slot('before')
  31. self.after = self.add_slot('after')
  32. self.separator = self.add_slot('separator')