I cannot click the Park button.
Maybe, the cause is the value of the park and one of station are the same.
I hope i can click the buttons separately.
What should I do.
import dash
from dash import dcc, html
from datetime import datetime as dt, timedelta
app = dash.Dash(__name__)
app.layout = html.Div([
html.H1("Depature time"),
html.Div([
html.Label("Form 1"),
dcc.Dropdown(
id='form1-dropdown',
options=[
{'label': 'Station', 'value': "10:00"},
{'label': 'Park', 'value': "10:00"},
{'label':'School','value':"20:00"}
],
multi=False,
value="00:00"
),
]),
html.Div([
html.Label("Form 2"),
dcc.Dropdown(
id='form2-dropdown',
options=[
{'label': 'Economy department', 'value': 10},
{'label': 'Sport field', 'value': 20},
{'label': 'Cafeteria', 'value': 40}
],
multi=False,
value=0
),
]),
html.Div(id='selected-options-output')
])
@app.callback(
dash.dependencies.Output('selected-options-output', 'children'),
[dash.dependencies.Input('form1-dropdown', 'value'),
dash.dependencies.Input('form2-dropdown', 'value')]
)
def display_selected_options(form1_selected_options, form2_selected_options):
###form1 as str
current_time = str(form1_selected_options)
###str to time
time_typed = dt.strptime(current_time, '%H:%M')
###add to time
timedelta_value = timedelta(minutes=form2_selected_options)
test = time_typed + timedelta_value
###format
formatted_time = test.strftime('%H:%M')
form2_text = formatted_time
return f"{form2_text}"
if __name__ == '__main__':
app.run_server(debug=True)