I like to have the output to be without []
and without ''
.
When nothing is selected, nothing should be displayed. If Some options are selected, then just the text, not the '' should be shown.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import time
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
dcc.Checklist(id='my-checklist1',
options=[
{'label': 'New York City', 'value': 'NYC'},
{'label': 'Montréal', 'value': 'MTL'},
{'label': 'San Francisco', 'value': 'SF'}
],
value=[]
),
html.Div(id='my-div-checklist1'),
html.Hr(),
dcc.Checklist(id='my-checklist2',
options=[
{'label': 'New York City', 'value': 'NYC'},
{'label': 'Montréal', 'value': 'MTL'},
{'label': 'San Francisco', 'value': 'SF'}
],
value=[],
labelStyle={'display': 'inline-block'}
),
html.Div(id='my-div-checklist2'),
html.Hr(),
])
@app.callback(Output('my-div-checklist1', 'children'),
[Input('my-checklist1', 'value'),
Input('my-checklist2', 'value')
])
def prepare_data(categ1, categ2):
return html.Div([dcc.Markdown(
'''{}, {}'''.format(categ1, categ2))])
if __name__ == '__main__':
app.run_server(debug=True)
Current vs. Expected:
Start now: [], []
What I want: ``
After selection now: 'NYC', 'SF'
What I want: NYC SF