Pyqt5自定义浏览器

时间:2021-08-05 11:15:48
from PyQt5.QtWebChannel import QWebChannel
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
from interactive import JavascriptBridge class Browser(QWebEngineView):
def __init__(self, *args, **kwargs):
super(Browser, self).__init__(*args, **kwargs)
self.pWebChannel = QWebChannel(self)
self.js_bridge = JavascriptBridge(self)
self.pWebChannel.registerObject("interactObj", self.js_bridge)
self.page().setWebChannel(self.pWebChannel)
# self.url = "https://wx5ec53535eb20a118.wx.qmgkj.cn/activity/dev/slider/#/record"
self.url = "https://baidu.com"
self.page().load(QUrl(self.url))