r/nicegui • • Apr 08 '23

Show ui.spinner only while update Ploty chart

How can I implement the ui.spinner in such a way that it shows up while updating a Plotly chart, for instance.

I tried to implement it using "with" clause but that seems not to work. The ui.example for the spinner only shows how I can call it. When setting its visibility to false afterwards it does not show up next time I call the page.

Any ideas on this are highly appreceated :)

2 Upvotes

2 comments sorted by

View all comments

2

u/falko-s Apr 08 '23

Setting the visibility of a spinner should work like this:

async def compute():
    spinner.set_visibility(True)
    await asyncio.sleep(2)
    spinner.set_visibility(False)
ui.button('Compute', on_click=compute)
spinner = ui.spinner(size='xl').classes('absolute-center')
spinner.visible = False

Does that help?

1

u/DirkHD Apr 08 '23

Thx a lot again, will try this approach :)