Hello Everyone
Hope you doing great !
I’m a beginner and I get some diffiulties to achieve what I want… Basically I would like n button that could share the same callback when they are clicked. The callback will then put the id of the specific button in a list and that’s it !
For the example i have took 2 button but in reality it has to be dynamic since the number of button is not fixed so the id and callback too
I have created a random div that could also be used has an output ! I have tried many solution of Matching Pattern but without success… So if anyone of you could help me it would be amazing
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
#List to stock when a button has been clicked we put the id of the button there
List_Interaction = []
#Simple div for output callback
Screen = html.Div(id='dd-output-container')
# Two Button that should have a dynamic id
Button1 = html.Button('Button 1',id='btn1',style={
'backgroundColor':'white'
})
Button2 = html.Button('Button 2',id='btn2',style={
'backgroundColor':'white'
})
#simple container to stock the Button
Container_div = html.Div(
[
Screen,
Button1,
Button2
],
style={
'position': 'absolute',
'left': '0px',
'top': '0px',
'margin-left': '0%',
'outline': '0',
'height': '100%',
'width': '100%',
},
id = 'container-div'
)
app.layout = html.Div([
Container_div
])
if __name__=='__main__':
app.run_server(host="localhost", port=5005,debug=False,dev_tools_ui=False)
So has you can see there, nothing big, only 2 buttons that are located in a div and i would like to make sort of we have a callback that will be called whenever one of those button is clicked. But it has to be dynamic since the number of button is not fixed !
Thanks a lot