当前位置: 首页>>代码示例>>Python>>正文


Python QWebEngineView.settings方法代码示例

本文整理汇总了Python中PyQt5.QtWebEngineWidgets.QWebEngineView.settings方法的典型用法代码示例。如果您正苦于以下问题:Python QWebEngineView.settings方法的具体用法?Python QWebEngineView.settings怎么用?Python QWebEngineView.settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWebEngineWidgets.QWebEngineView的用法示例。


在下文中一共展示了QWebEngineView.settings方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import settings [as 别名]
 def __init__(self, parent=None):
     super().__init__(parent)
     self.port = None
     view = QWebEngineView()
     settings = view.settings()
     settings.setAttribute(QWebEngineSettings.JavascriptEnabled, True)
     self._set_widget(view)
开发者ID:mehak,项目名称:qutebrowser,代码行数:9,代码来源:webengineinspector.py

示例2: MainWidow

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import settings [as 别名]
class MainWidow(QWidget):
    def __init__(self):

        super().__init__()
        self.view=QWebEngineView()
        self.myprofile=self.getProfile()
        self.page=QWebEnginePage(self.myprofile,None)

        # self.channel=QWebChannel()
        # self.myobject=myObject()
        # self.channel.registerObject("xdpy", self.myobject)
        # self.page.setWebChannel(self.channel)

        self.page.settings().AllowRunningInsecureContent=True;
        self.page.settings().JavascriptEnabled=True;
        self.view.page=self.page
        self.url=QUrl("")
        self.view.page.load(self.url)
        self.view.show()
        self.view.settings().JavascriptEnabled=True
    def js_callback(self,result):
        print("js_callback:{}".format(result))
    def injectJS(self,sourceCode,name):
        script = QWebEngineScript();
        script.setSourceCode(sourceCode)
        script.setName(name)
        script.setInjectionPoint(QWebEngineScript.DocumentCreation)
        script.setWorldId(QWebEngineScript.MainWorld)
        script.setRunsOnSubFrames(True)
        self.view.page.scripts().insert(script)
        self.page.scripts().insert(script)

    def getProfile(self):
        profile=QWebEngineProfile("myProfile")
        profile.cachePath="/home/yyk/Desktop/cache"
        jsFile = constants.QTWEBCHANNELJS_FILE
        with open(jsFile, encoding="UTF-8") as file:
            js = file.read()
        script = QWebEngineScript();
        script.setSourceCode(js)
        script.setName('qwebchannel.js')
        script.setInjectionPoint(QWebEngineScript.DocumentCreation)
        script.setWorldId(QWebEngineScript.MainWorld)
        script.setRunsOnSubFrames(False)
        profile.scripts().insert(script)
        return profile
开发者ID:yyk123,项目名称:XwareDesktop,代码行数:48,代码来源:test.py

示例3: parse_args

# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import settings [as 别名]
    parser = argparse.ArgumentParser()
    parser.add_argument('url', help='The URL to open')
    parser.add_argument('--plugins', '-p', help='Enable plugins',
                        default=False, action='store_true')
    if WEBENGINE:
        parser.add_argument('--webengine', help='Use QtWebEngine',
                            default=False, action='store_true')
    return parser.parse_args()


if __name__ == '__main__':
    args = parse_args()
    app = QApplication(sys.argv)

    if WEBENGINE and args.webengine:
        wv = QWebEngineView()
    else:
        wv = QWebView()

    wv.loadStarted.connect(lambda: print("Loading started"))
    wv.loadProgress.connect(lambda p: print("Loading progress: {}%".format(p)))
    wv.loadFinished.connect(lambda: print("Loading finished"))

    if args.plugins and not WEBENGINE:
        wv.settings().setAttribute(QWebSettings.PluginsEnabled, True)

    wv.load(QUrl.fromUserInput(args.url))
    wv.show()

    app.exec_()
开发者ID:zacanger,项目名称:z,代码行数:32,代码来源:single-site-browser.py


注:本文中的PyQt5.QtWebEngineWidgets.QWebEngineView.settings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。