splitter_documentation.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class SplitterDocumentation(UiElementDocumentation, element=ui.splitter):
  4. def main_demo(self) -> None:
  5. with ui.splitter() as splitter:
  6. with splitter.before:
  7. ui.label('This is some content on the left hand side.').classes('mr-2')
  8. with splitter.after:
  9. ui.label('This is some content on the right hand side.').classes('ml-2')
  10. def more(self) -> None:
  11. @self.demo('Advanced usage', '''
  12. This demo shows all the slots and parameters including a tooltip, a custom separator, and a callback.
  13. ''')
  14. def advanced_usage() -> None:
  15. with ui.splitter(horizontal=False, reverse=False, value=60,
  16. on_change=lambda e: ui.notify(e.value)) as splitter:
  17. ui.tooltip('This is the default slot.').classes('bg-green')
  18. with splitter.before:
  19. ui.label('This is the left hand side.').classes('mr-2')
  20. with splitter.after:
  21. ui.label('This is the right hand side.').classes('ml-2')
  22. with splitter.separator:
  23. ui.icon('lightbulb').classes('text-green')
  24. ui.number('Split value', format='%.1f').bind_value(splitter)
  25. @self.demo('Image fun', '''
  26. This demo shows how to use the splitter to display images side by side.
  27. ''')
  28. def image_fun() -> None:
  29. with ui.splitter().classes('w-72 h-48') \
  30. .props('before-class=overflow-hidden after-class=overflow-hidden') as splitter:
  31. with splitter.before:
  32. ui.image('https://cdn.quasar.dev/img/parallax1.jpg').classes('w-72 absolute-top-left')
  33. with splitter.after:
  34. ui.image('https://cdn.quasar.dev/img/parallax1-bw.jpg').classes('w-72 absolute-top-right')