简体   繁体   中英

Is there an Python function to refresh a dash app?

A Thread update the data every hour. I would like Dash app is refreshed automatically when Thread starting and Thread finishing. (like the button in the webbrowser)

class RemplisseurDB(Thread):
    def __init__(self):
        Thread.__init__(self)

    def run(self):

        while True:

            global layout_mess
            layout_mess = 0
            global dfusin
            dfusin = pd.read_excel('path\Planning Usinage.xlsm', sheet_name='Interface_Data')

            now = datetime.now()
            end = datetime(now.year,now.month,now.day,now.hour + 1 ,0,0)
            self.attente = (end - now).seconds
            layout_mess = 1
            time.sleep(self.attente)


def affich():
    if layout_mess == 0:
        return html.Div(children=[
        html.H2(id='update0',children='Update in progress, please wait few minutes ....')])`

    else:
        return html.Div([
        html.H2(id='update1',children='work space')])`


app.layout=affich

I came across this Dash component which seems to fit your needs https://dash.plotly.com/live-updates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM