holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.76k stars 517 forks source link

pn.state.sync_busy(widget_column) #2528

Open andhuang-CLGX opened 3 years ago

andhuang-CLGX commented 3 years ago

Would be really useful to be able to do

import panel as pn
pn.extension()
widget_column = pn.WidgetBox(pn.widgets.Button())
pn.state.sync_busy(widget_column)
andhuang-CLGX commented 3 years ago

Right now, for each function I do

        widget_column.loading = True
        ...
        widget_column.loading = False
mathrick commented 3 years ago

In my experience pn.state.sync_busy() is not terribly useful in general though, since it doesn't actually reflect whether your application is busy, only whether a python function is currently blocking Tornado (I think technically it is whether a comm is currently awaiting a response?). So if you do your processing async / in a thread, which you have to do to keep from blocking all users, the busy spinner will never reflect the true busy state of your app.

MarcSkovMadsen commented 3 years ago

If you want multiple spinners you can use start_loading_spinner and stop_loading_spinner functions in panel.io.loading.