@fabianexe wrote:
Hi,
I have an app where the user gives some input, and the app then loads some data and visualize them in an extra Tab. Because this loading takes some time, I want to disable the Tab until data is loaded. However, this is not working as I was expecting. The Tab is never disabled. Below I provide a minimal example of my callbacks.
The idea is to click the “Fire” button, and then the “Tab two” shout be disabled. After the “do_process” callback is finished, it should be enabled again.
What do I miss that this not work?
Thanks for the help in advance.import dash import dash_html_components as html import dash_core_components as dcc import time app = dash.Dash(__name__) app.layout = html.Div([ dcc.Tabs([ dcc.Tab(label='Tab one', id='tab1'), dcc.Tab(label='Tab two', id='tab2') ]), html.Button("Fire", id='btn1'), dcc.Input(value='', type='hidden', id='start'), dcc.Input(value='', type='hidden', id='stop'), ]) @app.callback(dash.dependencies.Output('start', 'value'), [dash.dependencies.Input('btn1', 'n_clicks')]) def start_process(n_clicks): return n_clicks @app.callback(dash.dependencies.Output('stop', 'value'), [dash.dependencies.Input('start', 'value')]) def do_process( value): time.sleep(5) return value @app.callback(dash.dependencies.Output('tab2', 'disabled'), [dash.dependencies.Input('start', 'value'), dash.dependencies.Input('stop', 'value')]) def manage_tab(value1, value2): ctx = dash.callback_context trigger = ctx.triggered[0]['prop_id'].split('.')[0] if trigger == 'start': return True return False if __name__ == '__main__': app.run_server(debug=True)
Posts: 1
Participants: 1