Skip to content

Commit

Permalink
Simple nesting elements inside circular_progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Aug 26, 2023
1 parent 0b66e87 commit cf9bbd3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nicegui/elements/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self,
self._props['min'] = min
self._props['max'] = max
self._props['size'] = size
self._props['show-value'] = show_value
self._props['show-value'] = True # NOTE always activate the default slot because this is expected by ui.element
self._props['track-color'] = 'grey-4'

if show_value:
Expand Down
17 changes: 17 additions & 0 deletions website/more_documentation/circular_progress_documentation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
from nicegui import ui

from ..documentation_tools import text_demo


def main_demo() -> None:
slider = ui.slider(min=0, max=1, step=0.01, value=0.5)
ui.circular_progress().bind_value_from(slider, 'value')


def more() -> None:
@text_demo('Nested Elements', '''
You can put any element like icon, button etc inside a circular progress using the `with` statement.
Just make sure it fits the bounds and disable the default behavior of showing the value.
''')
def icon() -> None:
with ui.row().classes('items-center m-auto'):
with ui.circular_progress(value=0.1, show_value=False) as progress:
ui.button(
icon='star',
on_click=lambda: progress.set_value(progress.value + 0.1)
).props('flat round')
ui.label('click to increase progress')

0 comments on commit cf9bbd3

Please sign in to comment.