How do I add loading indicator to a holoviz panel which is displayed while some computation is done?

Hi,

I posted a question on stackoverflow: python 3.x - How do I add loading indicator to a holoviz panel which is displayed while some computation is done? - Stack Overflow

I just discovered this community, and re-posting the same here. Below are the question details:

I am working on a project which uses the holoviz panel for display. The panel has a button which does some heavy computation on click and displays result after a few seconds. How do I modify the code such that I get a loading indicator(spinner) while data is being fetched? I probably need to add loading_indicator = True somewhere(pass as parameter), but haven’t had any success so far. Is there an alternate way? Minimal code:

import panel as pn
import pandas as pd

pn.extension()

submit_button = pn.widgets.Button(name='Submit', button_type='primary', width = 180)
radio_buttons_group = pn.widgets.RadioButtonGroup(options=['Ying', 'Yang'], button_type='default')
outer_col = pn.Column(radio_buttons_group, submit_button)

@pn.depends(submit_button.param.clicks, watch=True)
def display_result(event):
    if(len(outer_col) > 2):
        outer_col.pop(len(outer_col)-1)

    if(radio_buttons_group.value == 'Ying'):
        ying_view()
    else:
        yang_view()
        
def ying_view():
    #some heavy computation
    outer_col.append(pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})) #sample
    
def yang_view():
    #some heavy computation
    outer_col.append(pd.DataFrame({'col1': [5, 6], 'col2': [7, 8]})) #sample
    
outer_col                                                            #displays the result

I just want to include the (bare minimum) loading indicator. Nothing fancy please.
Thanks in advance!

Hi @argcv,

You’ll find the holoviz discourse (panel, holoviews and others) community here where you might find better response to this question as it’s specific to panel rather than bokeh.

https://discourse.holoviz.org/

Thanks, Carl.

1 Like

Thanks Carl