Skip to content

Instantly share code, notes, and snippets.

@grst
Created January 20, 2019 15:55
Show Gist options
  • Save grst/dee7e6a56b46c9b29e692ce8d7fa823c to your computer and use it in GitHub Desktop.
Save grst/dee7e6a56b46c9b29e692ce8d7fa823c to your computer and use it in GitHub Desktop.
slow dropdown in dash
import dash
import dash_html_components as html
import dash_core_components as dcc
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
dcc.Dropdown(
id='dropdown-selector',
options=[
{'label' : 'no-dropdown', 'value' : 'no-dropdown' },
{'label' : 'dropdown', 'value' : 'dropdown' }
],
value='no-dropdown'
),
html.Div(id='container')
])
@app.callback(
dash.dependencies.Output('container', 'children'),
[dash.dependencies.Input('dropdown-selector', 'value')])
def update_output(value):
if value == "dropdown":
return dcc.Dropdown(
id='my-dropdown',
options=[
{'label': 'gene_{}'.format(i), 'value': 'gene_{}'.format(i)} for i in range(100000)
],
multi=True
)
if __name__ == '__main__':
app.run_server(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment