splitter_documentation.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from nicegui import ui
  2. from ..documentation_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.')
  7. with splitter.after:
  8. ui.label('This is some content on the right hand side.')\
  9. .classes('ml-2')
  10. def more() -> None:
  11. @text_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.')
  20. with splitter.after:
  21. ui.label('This is the right hand side.') \
  22. .classes('ml-2')
  23. with splitter.separator:
  24. ui.icon('lightbulb').classes('text-green')
  25. ui.number('Split value', format='%.1f').bind_value(splitter)
  26. @text_demo('Image fun', '''
  27. This demo shows how to use the splitter to display images side by side.
  28. ''')
  29. def image_fun() -> None:
  30. with ui.splitter().classes('w-72 h-48') \
  31. .props('before-class=overflow-hidden after-class=overflow-hidden') as splitter:
  32. with splitter.before:
  33. ui.image('https://cdn.quasar.dev/img/parallax1.jpg').classes('w-72 absolute-top-left')
  34. with splitter.after:
  35. ui.image('https://cdn.quasar.dev/img/parallax1-bw.jpg').classes('w-72 absolute-top-right')