I’m using the dcc.tabs
in a bare-bones app, and a simple callback (using html.Button
) responds very slowly when inside a tab. It takes more than a minute after clicking the submit button before the response_div
updates. I also experienced this in a more sophisticated app (4 tabs, multiple graphs, etc.) and the response-div
took upwards of 5 minutes to update after clicking submit
, or just bombed out completely. In both cases, the identical code works fine when not using dcc.tabs
. Has anyone else experienced this? Am I missing something obvious? Full code for short app is below. Using dash-core-components-0.28.1
.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
app = dash.Dash()
application = app.server
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = html.Div([
html.H1('Dash Tabs component demo', style={
'textAlign': 'center', 'margin': '48px 0', 'fontFamily': 'system-ui'}),
dcc.Tabs(id="tabs", children=[
dcc.Tab(label='Tab one', children=[
html.Div([
html.H3('Type any number in the box:'),
dcc.Input(
id='number-in',
value=1,
style={'fontSize':20}
),
html.Button(
id='submit-button',
n_clicks=0,
children='Submit',
style={'fontSize':20}
),
html.H4(id="response_div"),
],
className='twelve columns'),
]),
dcc.Tab(label='Tab two', children=[
html.Div([
html.H1("This is the content in tab 2"),
html.P("A graph here would be nice!")
])
]),
dcc.Tab(label='Tab three', children=[
html.H1("This is the content in tab 3"),
html.P("Insert content here")
]),
]),
])
# ------------------------#
# CALLBACKS #
# ------------------------#
# Call topic number
@app.callback(
Output('response_div', 'children'),
[Input('submit-button', 'n_clicks')],
[State('number-in', 'value')])
def output(n_clicks, number):
return 'The number you have picked is: {}'.format(number),
if __name__ == '__main__':
application.run(debug=True, port=8020)