Hello,
I’d like to make a complex page which allows me to read text/options from inputs. First of all I’d like to make a button that invoke a method and pass text from textarea after click on it. This is my code, I don’t want send anything to output. How to do it?
management_page= html.Div([
dcc.Input(id='name',placeholder='Enter a value...',type='text',value=''),
html.Button(id='button',value='Click')
])
@app.callback(Output(),[Input('button','value')],
)
def addNew(value):
addTab(str(value))
use the property n_clicks instead of value
Look here - I have these tabs.
If i click on tab “Management” callback is called - i don;t want it. When I click on button callback is called and property n_clicks is updated.
Callback invoke other methods which have to be invoked only when button is clicked
My code now:
management_page= html.Div([
dcc.Input(id='name',placeholder='Type a name',type='text',value=''),
html.Br(),
"Choose elements",
dcc.Dropdown(id='dropd',options=[
{'label': 'g1', 'value': 'g'},
{'label': 'b1', 'value': 'b'},
],
multi=True),
html.Button(id='button',n_clicks=0)
])
@app.callback(Output('name','value'),[Input('button','n_clicks')],
)
def addNew(click):
#other methods here
EDIT: So, I’ve decided to use time_stamp. Now my code looks like this:
@app.callback(Output('name','value'),[Input('button','n_clicks_timestamp')],
)
def addNew(click):
pprint(klik)
if click is not None:
#my code here
else:
return #do nothing
So, I think it’s done
1 Like