Hi there,
I have a submit button which I expect the following behavior:
click submit button
deactivate button and run some time consuming jobs
Once the jobs are done, enable the submit button
What I need to help is, is it possible to return ‘disabled’ state at first (because jobs are executing) and then return an ‘active’ state once jobs are done. Generally speaking, is it possible to deactivate a button for some time spans?
I’ve search posts in the community but did’t find an answer which really solves my problem.
Thank you for your help!
Here are my codes:
</
dbc.Button(‘Clickme’,
id = ‘btn’,
disabled = False
)
@app.callback(
Output(“btn”, “disabled”),
Input(“btn”, “n_clicks”),
State(“btn”, “disabled”),
)
def deactivate_btn_while_running(n1, disabled):
print(n1, disabled)
# execute some computing jobs
# if not done return disabled (need help)
# else return not disabled (need)
Dear @jinnyzor, thank you for your answer and this it what I’m searching for. However, when I execute the code from the example 2, I’ve got the following error. Is this due to my python package?
I mean background callback works correctly under one single app.py. However, my app is using multiple page and therefore I still get error due to dill.
I ran into the same issue (cannot pickle '_abc._abc_data') using dill 0.3.6. This issue is fixed in dill 0.3.7. However, another issue came up, which for me was related to ContextVar not being pickle-able.
I found out that the root cause was related to using @app.callback to define callbacks rather than using from dash import callback in combination with @callback.