✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

How to disable button till finish a function and be enable again using python and html.Button

I have just tried to create a loading component as to make the button disabled but I couldn’t know how to make it disabled during the process in def called my_DB_func(), this the below just create the loading till this function is finished, but on ther hand I want to disable this button till the process finish So how Can I do this

this is my full code:

import dash
import dash_html_components as html
import dash_core_components as dcc
import time
from Missing_relation_All import my_DB_func

from dash.dependencies import Input, Output, State

app = dash.Dash(__name__)

app.layout = html.Div(
    children=[
        html.Button('Create Missing Relation Script', id='input-1', disabled=False),
        dcc.Loading(id="loading-1", children=[html.Div(id="loading-output-1")], type="default"),
    ],
)

@app.callback(Output("loading-output-1", "children"), [Input("input-1", "n_clicks")])
def input_triggers_spinner(n_clicks):
    if n_clicks == True:
        my_DB_func()
        return 'Script have been created successful :) !!!!'


    elif n_clicks != True:
        return 'Please Click Here'


if __name__ == "__main__":
    app.run_server(debug=False)