1
0

button_documentation.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. from nicegui import ui
  2. from ..documentation_tools import text_demo
  3. def main_demo() -> None:
  4. ui.button('Click me!', on_click=lambda: ui.notify(f'You clicked me!'))
  5. def more() -> None:
  6. @text_demo('Icons', '''
  7. You can also add an icon to a button.
  8. ''')
  9. async def icons() -> None:
  10. with ui.row():
  11. ui.button('demo').props('icon=history')
  12. ui.button().props('icon=thumb_up')
  13. with ui.button():
  14. ui.label('sub-elements')
  15. ui.image('https://picsum.photos/id/377/640/360') \
  16. .classes('rounded-full w-16 h-16 ml-4')
  17. @text_demo('Await button click', '''
  18. Sometimes it is convenient to wait for a button click before continuing the execution.
  19. ''')
  20. async def await_button_click() -> None:
  21. # @ui.page('/')
  22. # async def index():
  23. b = ui.button('Step')
  24. await b.clicked()
  25. ui.label('One')
  26. await b.clicked()
  27. ui.label('Two')
  28. await b.clicked()
  29. ui.label('Three')