【问题标题】: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,所以它应该可以工作。