【问题标题】:Reload/Refresh a webpage using pywebview library in python在 python 中使用 pywebview 库重新加载/刷新网页
【发布时间】:2020-12-08 22:07:39
【问题描述】:

是否可以使用 pywebview 库重新加载网页? 我的意思是,我有这个代码:

import webview

webview.create_window('Woah dude!', 'index.html')
webview.start(http_server=True)

...我想每五秒重新加载一次网页,因为 HTML 文件正在发生变化。

【问题讨论】:

    标签: python webview reload restart pywebview


    【解决方案1】:

    尝试这样做:

    import webview
    import time
    
    def reload(window):
        while True:
            time.sleep(5)
            window.load_url('index.html')
            
            
    if __name__ == '__main__':
        window = webview.create_window('hello', 'index.html')
    
        webview.start(reload, window, http_server=True)
    
            
    

    这将每 5 秒“重新加载”一次页面。它并不是真正重新加载它,它基本上是在加载相同的 url,所以它应该可以工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-03
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      • 2010-12-24
      • 2016-11-26
      • 2011-12-14
      • 2020-11-17
      相关资源
      最近更新 更多