Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Change dash Checklist values by callback

$
0
0

I would like to change the selected options of an plotly dash checklist by an callback. My minimal working example is as following but it doesn’t work for now. (Values should change by hitting the ‘load’ button → at loading the page, nothing ist selected, after click the button ‘SF’ should be selected):

import dash

app = dash.Dash(__name__)

app.layout = html.Div([

    dcc.Checklist(
    options=[
        {'label': 'New York City', 'value': 'NYC'},
        {'label': 'Montréal', 'value': 'MTL'},
        {'label': 'San Francisco', 'value': 'SF'}
    ],
    labelStyle={'display': 'block'},
    value=[]
    ),  

    html.Button('load', id='load-button', n_clicks=0)
])

@app.callback(Output('checkliste', 'value'),
              Input('load-button', 'n_clicks'))
def change_values(n_clicks):
    if n_clicks > 1:
        return ['SF']



if __name__ == '__main__':
    app.run_server(debug=False)

Hope, someone can help!

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 6271

Latest Images

Trending Articles



Latest Images