1
0

splitter_documentation.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.splitter)
  4. def main_demo() -> 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. @doc.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. @doc.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')
  34. doc.reference(ui.splitter)