是否有一个Python函数来刷新dash应用程序?

2024-09-30 22:26:35 发布

您现在位置:Python中文网/ 问答频道 /正文

线程每小时更新一次数据。我想破折号应用程序是自动刷新时,线程开始和线程完成(就像网络浏览器中的按钮)

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

Tags: selfdatetimeinitdefhtml线程globalthread