你好,我在Dash中设计了3个按钮,当按钮被点击时,我想改变按钮的颜色,我知道需要在@app.callback中进行更改,但是我不确定要更改什么。 我希望保持一切不变,只需将颜色更改为"红色"
有人能帮帮我吗?
leftButtons = html.Div(id='framework-left-pane',
children=[
dcc.Link( children = html.Button(leftButton1,
id='leftbutton1',
className='roundbutton',
style={'backgroundColor': '#111100', 'color':'white','width':'100%', 'border':'1.5px black solid', 'height': '50px','text-align':'center', 'marginLeft': '20px', 'marginTop': 130}, n_clicks = 0)),
dcc.Link( children = html.Button(leftButton2,
id='leftbutton2',
className='roundbutton',
style={'backgroundColor': '#111100', 'color':'white','width':'100%' , 'border':'1.5px black solid','height': '50px','text-align':'center', 'marginLeft': '20px', 'marginTop': 20},n_clicks = 0)),
dcc.Link( children = html.Button(leftButton3,
id='leftbutton3',
className='roundbutton',
style={'backgroundColor': '#111100', 'color':'white','width':'100%', 'border':'1.5px black solid','height': '50px','text-align':'center', 'marginLeft': '20px', 'marginTop': 20},n_clicks = 0)),
],style={'width':'200px','position':'fixed'})
目前,使用app.callback时,我只返回一张图片。
@app.callback(
Output(component_id='tab_1_images', component_property='children'),
[Input('leftbutton1', 'n_clicks'),
Input('leftbutton2', 'n_clicks'),
Input('leftbutton3', 'n_clicks')])
def update_output_div(n_clicks_A, n_clicks_B, n_clicks_C):
return [a static image for each of the button]