pyqt5 用 pynput 去更新 QWebEngineView 一直出诡异的错?
from PyQt5.QtCore import Qt, QUrlfrom PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
from pynput import keyboard as kb
from threading import Thread
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Webengine Refresh Example")
# Create webengine view widget
self.web_view = QWebEngineView()
self.web_view.load(QUrl("https://www.example.com"))
# Add webengine view to your main window
self.setCentralWidget(self.web_view)
# Initialize keyboard listener thread
self.keyboard_thread = Thread(target=self.keyboard_listener)
self.keyboard_thread.daemon = True
def keyboard_listener(self):
with kb.GlobalHotKeys({"<ctrl>+r": self.on_keyboard_press}) as listener:
listener.join()
def on_keyboard_press(self):
# Reload webengine view
self.web_view.reload()
if __name__ == "__main__":
app = QApplication([])
window = MainWindow()
window.show()
window.keyboard_thread.start()
app.exec_()
window.keyboard_thread.join()
我想是在即使窗口不还聚集的情况下,也能触发刷新,
但是一按键 就是报
Exception: python3 exited with 3221225477
还 try except 不行
以上是 pyqt5 用 pynput 去更新 QWebEngineView 一直出诡异的错? 的全部内容, 来源链接: utcz.com/p/938781.html