I want to develop a button after I clicked it, after 5 seconds it will do the command that I code.
how can I do that?
I tried using dcc.Interval and it does not the job
I want to develop a button after I clicked it, after 5 seconds it will do the command that I code.
how can I do that?
I tried using dcc.Interval and it does not the job
You can just use the time module to pause the code for a fixed number of seconds (https://docs.python.org/3/library/time.html). time.sleep(n) will pause your code for n seconds before the next line executes:
import time
...
@app.callback(
Output('some-output', 'value'),
[Input('some-input', 'value')]
def delayed_callback(input):
time.sleep(5) #wait 5 seconds
# Code to do something
return output