Hi all,
I have a problem with one of my callbacks that should populate a dropdown when a file is selected in the uploader. However, nothing happens. I have created the following minimal example which does not work on my end (the dropdown does not change, nor does the debug message get printed on the console). Is this a bug, or am I doing something wrong?
Thanks for your help!
Daniel
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import sys
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Dropdown Test'),
dcc.Dropdown(id='the-dropdown',
options=[{'label': 'foo', 'value': 'bar'}]),
dcc.Upload(id='the-uploader', children=html.Div([
'Drag and Drop or ', html.A('Select File')
]),
style={
'width': '100%',
'height': '60px',
'lineHeight': '60px',
'borderWidth': '1px',
'borderStyle': 'dashed',
'borderRadius': '5px',
'textAlign': 'center',
'margin': '10px'
}
)
])
@app.callback(Output('the-dropdown', 'options'),
[Input('the-uploader', 'contents')])
def load_dropdown(the_file):
print('load references called', file=sys.stderr)
if the_file:
return [{'label': 'bla', 'value': 'bla'}]
else:
return None
if __name__ == '__main__':
app.run_server(debug=True)