circular_progress_documentation.py 849 B

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. from . import doc
  3. @doc.demo(ui.circular_progress)
  4. def main_demo() -> None:
  5. slider = ui.slider(min=0, max=1, step=0.01, value=0.5)
  6. ui.circular_progress().bind_value_from(slider, 'value')
  7. @doc.demo('Nested Elements', '''
  8. You can put any element like icon, button etc inside a circular progress using the `with` statement.
  9. Just make sure it fits the bounds and disable the default behavior of showing the value.
  10. ''')
  11. def icon() -> None:
  12. with ui.row().classes('items-center m-auto'):
  13. with ui.circular_progress(value=0.1, show_value=False) as progress:
  14. ui.button(
  15. icon='star',
  16. on_click=lambda: progress.set_value(progress.value + 0.1)
  17. ).props('flat round')
  18. ui.label('click to increase progress')
  19. doc.reference(ui.circular_progress)