splitter_documentation.py 1.7 KB

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