1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| import time import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output, State
app = dash.Dash(__name__)
app.layout = html.Div( [ html.H3('Loading Test'),
dcc.Dropdown(id='dropdown1', options=[ {'label':'default', 'value':'default'}, {'label':'graph', 'value':'graph'}, {'label':'cube', 'value':'cube'}, {'label':'circle', 'value':'circle'}, {'label':'dot', 'value':'dot'} ] ), html.Button(id='button1', children="Push"), html.Br(), html.Br(), html.Br(), html.Br(), html.Br(), html.Br(), dcc.Loading( id='loading1', children=[html.H1(id='loading', style={'margin':100})] ) ], style={'textAlign':'center'} )
@app.callback( Output('loading1', 'type'), Input('dropdown1', 'value') ) def set_loading_type(dropdown1): print('set_loading_type', dropdown1) return dropdown1
@app.callback( Input('button1', 'n_clicks') ) def start_loading(n_clicks): print('start_loading', n_clicks) time.sleep(5) return
if __name__ == '__main__': app.run_server(debug=True)
|