Pyqt5自定义浏览器

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))

 

posted @ 2019-02-27 22:32  Leslie-x  阅读(617)  评论(0编辑  收藏  举报