circular_progress_documentation.py 1.0 KB

123456789101112131415161718192021222324
  1. from nicegui import ui
  2. from ...model import UiElementDocumentation
  3. class CircularProgressDocumentation(UiElementDocumentation, element=ui.circular_progress):
  4. def main_demo(self) -> 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. def more(self) -> None:
  8. @self.demo('Nested Elements', '''
  9. You can put any element like icon, button etc inside a circular progress using the `with` statement.
  10. Just make sure it fits the bounds and disable the default behavior of showing the value.
  11. ''')
  12. def icon() -> None:
  13. with ui.row().classes('items-center m-auto'):
  14. with ui.circular_progress(value=0.1, show_value=False) as progress:
  15. ui.button(
  16. icon='star',
  17. on_click=lambda: progress.set_value(progress.value + 0.1)
  18. ).props('flat round')
  19. ui.label('click to increase progress')