hi everyone,
i’m trying to make it so that when i reach a specific value on my slider, a specific command is executed. this is the code i’ve gotten close to success with, but it still yields no results. does anyone have any advice on what i can do to make this work? thank you
app.layout = html.Div([
dcc.Slider(0, 10,
id='gain',
step=1,
value=0,
marks={
1: {'label': '1 nA', 'style': {'color':'#7EAE86'}},
2: {'label': '10 nA', 'style': {'color':'#7EAE86'}},
3: {'label': '100 nA', 'style': {'color':'#7EAE86'}},
4: {'label': '1 µA', 'style': {'color':'#7E95AE'}},
5: {'label': '10 µA', 'style': {'color':'#7E95AE'}},
6: {'label': '100 µA', 'style': {'color':'#7E95AE'}},
7: {'label': '1 mA', 'style': {'color':'#9B7EAE'}},
8: {'label': '10 mA', 'style': {'color':'#9B7EAE'}},
9: {'label': '50 mA', 'style': {'color':'#9B7EAE'}},
}
),
html.Div(id='slider')
])
@app.callback(
Output('slider', 'children'),
Input('gain', 'value'))
def update_output(value):
if value == 1:
g0 = inst.write('GAIN 0')
return [g0, 'set to 0']
elif value == 2:
g1 = inst.write('GAIN 1')
return g1
elif value == 3:
g2 = inst.write('GAIN 2')
return g2
elif value == 4:
g3 = inst.write('GAIN 3')
return g3
elif value == 5:
g4 = inst.write('GAIN 4')
return g4
elif value == 6:
g5 = inst.write('GAIN 5')
return g5
elif value == 7:
g6 = inst.write('GAIN 6')
return g6
elif value == 8:
g7 = inst.write('GAIN 7')
return g7
elif value == 9:
g8 = inst.write('GAIN 8')
return g8