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


Python QtWebEngineWidgets.QWebEngineView类代码示例

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


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

示例1: __init__

    def __init__(self, inspector=False):
        QWebEngineView.__init__(self)

        self.__inspector = None
        self.__contextMenuEvent = self.contextMenuEvent

        self.set_inspector(inspector)
开发者ID:kororaproject,项目名称:kp-lens,代码行数:7,代码来源:appqt5webengine.py

示例2: __init__

 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,代码行数:7,代码来源:webengineinspector.py

示例3: print_to_pdf

def print_to_pdf(html, pdf_file):
    from PyQt5.QtCore import QUrl
    from PyQt5 import QtGui, QtCore

    global qapp
    if qapp is None:
        qapp = QApplication(['--disable-gpu', '--disable-extension'])

    view = QWebEngineView()
    page = QWebEnginePage()
    view.setPage(page)

    def pdf_printed(*args, **kwargs):
        page.pdfPrintingFinished.disconnect()
        page.loadFinished.disconnect()
        qapp.quit()

    def page_loaded(*args, **kwargs):
        page.pdfPrintingFinished.connect(pdf_printed)
        page.printToPdf(
            pdf_file,
            QtGui.QPageLayout(
                QtGui.QPageSize(QtGui.QPageSize.A4), QtGui.QPageLayout.Portrait, QtCore.QMarginsF(25, 25, 25, 25)
            )
        )

    page.loadFinished.connect(page_loaded)

    if isinstance(html, bytes):
        html = html.decode('utf-8')
    view.setHtml(html, QUrl('file://'))
    qapp.exec_()
    return os.path.basename(pdf_file)
开发者ID:katrid,项目名称:orun,代码行数:33,代码来源:__init__.py

示例4: __init__

 def __init__(self, html):
     self.html = None
     self.app = QApplication(sys.argv)
     QWebEngineView.__init__(self)
     self.loadFinished.connect(self._loadFinished)
     self.setHtml(html)
     while self.html is None:
         self.app.processEvents(QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers | QEventLoop.WaitForMoreEvents)
     self.app.quit()
开发者ID:FrancescoZ,项目名称:Chemception,代码行数:9,代码来源:utils.py

示例5: test1

def test1():
    app = QApplication(sys.argv)
    window = QMainWindow()
    window.setWindowTitle('PyQt Demo')
    window.setGeometry(320, 180, 960, 540)
    view = QWebEngineView()
    # view.load(QUrl('http://leafletjs.com/'))
    view.load(QUrl('https://www.raspberrypi.org/'))
    window.setCentralWidget(view)
    window.show()

    sys.exit(app.exec_())
开发者ID:kamijawa,项目名称:pi_server,代码行数:12,代码来源:test_pyqt5.py

示例6: Example

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(640, 320)
        self.setWindowTitle('PyQt-5 WebEngine')

        page = "https://www.google.com"

        self.url = QLineEdit(page)
        self.url.setPlaceholderText(page)

        self.go = QPushButton("Ir")
        self.go.clicked.connect(self.btnIrClicked)

        self.nav_bar = QHBoxLayout()
        self.nav_bar.addWidget(self.url)
        self.nav_bar.addWidget(self.go)

        self.progress = QProgressBar()
        self.progress.setValue(0)

        html = """
        <!DOCTYPE HTML>
            <html>
                <head>
                    <title>Example Local HTML</title>
                </head>
                <body>
                    <p>Este es un archivo <code>HTML</code> local.</p>
                    <p>Si deseas acceder página indica su <code>URL</code> y presiona <b>Ir</b></p>
                </body>
            </html>
        """

        self.web_view = QWebEngineView()
        self.web_view.loadProgress.connect(self.webLoading)
        self.web_view.setHtml(html)

        root = QVBoxLayout()
        root.addLayout(self.nav_bar)
        root.addWidget(self.web_view)
        root.addWidget(self.progress)

        self.setLayout(root)

    def btnIrClicked(self, event):
        url = QUrl(self.url.text())
        self.web_view.page().load(url)

    def webLoading(self, event):
        self.progress.setValue(event)
开发者ID:TutorProgramacion,项目名称:pyqt-tutorial,代码行数:51,代码来源:web.py

示例7: Ui_MainWindow

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.qwebengine = QWebEngineView(self.centralwidget)
        self.qwebengine.setGeometry(QtCore.QRect(10, 30, 451, 321))
        self.qwebengine.setAutoFillBackground(False)
        self.qwebengine.setStyleSheet("background-color: rgb(170, 170, 127);")
        self.qwebengine.setObjectName("qwebengine")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
开发者ID:kiorry,项目名称:PYQT,代码行数:26,代码来源:Ui_plotly_pyqt.py

示例8: __init__

    def __init__(self, tab,
                 editorPositionToSourceLineFunc,
                 sourceLineToEditorPositionFunc):

        QWebEngineView.__init__(self, parent=tab)
        webPage = ReTextWebEnginePage(self, tab)
        self.setPage(webPage)

        self.syncscroll = SyncScroll(webPage,
                                     editorPositionToSourceLineFunc,
                                     sourceLineToEditorPositionFunc)
        ReTextWebPreview.__init__(self, tab.editBox)

        settings = self.settings()
        settings.setAttribute(QWebEngineSettings.LocalContentCanAccessFileUrls,
                              False)
开发者ID:starofrainnight,项目名称:retext,代码行数:16,代码来源:webenginepreview.py

示例9: initUI

    def initUI(self, windowType):
        self.setStyleSheet("""
            #cmdLine, #bar, #bar > * { border: 0px; background: #070707; font-family: "Pro Font"; font-size: 10px; color: white; min-height: 17px }
        """)

        self.setWindowTitle('shower')
        self.setAttribute(Qt.WA_DeleteOnClose)

        vbox = QVBoxLayout()
        self.setLayout(vbox)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)

        bar = QWidget()
        bar.setObjectName('bar')
        hbox = QHBoxLayout()
        hbox.setContentsMargins(2, 0, 0, 0)
        hbox.setSpacing(0)
        bar.setLayout(hbox)
        vbox.addWidget(bar)

        self.urlLabel = QLabel()
        self.urlLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
        self.urlLabel.setTextFormat(Qt.RichText)
        hbox.addWidget(self.urlLabel)
        hbox.setStretch(0, 1)

        self.progressLabel = QLabel()
        self.progressLabel.setTextFormat(Qt.RichText)
        hbox.addWidget(self.progressLabel)

        self.cmdLine = QLineEdit()
        self.cmdLine.setObjectName('cmdLine')
        vbox.addWidget(self.cmdLine)

        self.webView = QWebEngineView()
        self.webView.setPage(BrowserPage(self))
        vbox.addWidget(self.webView)

        self.cmdLine.returnPressed.connect(self.handleCommand)

        self.webView.page().linkHovered.connect(self.onLinkHovered)
        self.webView.page().urlChanged.connect(self.urlChanged)
        self.webView.page().titleChanged.connect(self.onTitleChanged)
        self.webView.page().loadProgress.connect(self.onLoadProgress)
        self.webView.page().loadStarted.connect(self.onLoadStarted)
        self.webView.page().loadFinished.connect(self.onLoadFinished)

        self.urlChanged.connect(self.onUrlChanged)

        self.addShortcut("Alt+Left", lambda: self.webView.page().triggerAction(QWebEnginePage.Back))
        self.addShortcut("Alt+Right", lambda: self.webView.page().triggerAction(QWebEnginePage.Forward))
        self.addShortcut("Ctrl+R", lambda: self.webView.page().triggerAction(QWebEnginePage.Reload))
        self.addShortcut("Ctrl+Shift+R", lambda: self.webView.page().triggerAction(QWebEnginePage.ReloadAndBypassCache))
        self.stopShortcut = self.addShortcut("Esc", lambda: self.webView.page().triggerAction(QWebEnginePage.Stop))
        self.addShortcut("Ctrl+W", lambda: self.close())
        self.addShortcut("Ctrl+L", lambda: self.beginEnteringCommand(None))
        self.addShortcut("Ctrl+K", lambda: self.beginEnteringCommand('? '))
        self.addShortcut("Ctrl+/", lambda: self.beginEnteringCommand('/ '))
        self.addShortcut("Ctrl+U", lambda: self.toggleSource())
开发者ID:Waldteufel,项目名称:shower,代码行数:60,代码来源:BrowserWindow.py

示例10: obtain_code

    def obtain_code(self, url=SandBoxURL, state=""):
        """Obtain an application code

        :param url: A Base url for requests, optional
        :param state: Additional if to be returned, optional
        """
        self.app = QApplication([])

        payload = {
            "response_type": "code",
            "client_id": client_id,
            "redirect_uri": oauth2_redirect,
            "scope": scope,
            "state": state,
        }

        res = requests.get(url + "/v3/auth/auth", params=payload, headers=headers)

        self.webview = QMainWindow()

        self.engine = QWebEngineView()
        self.engine.setUrl(QUrl(res.url))
        self.engine.urlChanged.connect(self.parse_code)

        self.webview.setCentralWidget(self.engine)
        self.webview.show()
        self.app.exec_()
开发者ID:TylorS,项目名称:refeed,代码行数:27,代码来源:qt.py

示例11: mainPyQt5

def mainPyQt5():
    # 必要なモジュールのimport
    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtCore import QUrl
    from PyQt5.QtWebEngineWidgets import QWebEngineView

    url = "https://github.com/tody411/PyIntroduction"

    app = QApplication(sys.argv)

    # QWebEngineViewによるWebページ表示
    browser = QWebEngineView()
    browser.load(QUrl(url))
    browser.show()

    sys.exit(app.exec_())
开发者ID:tody411,项目名称:PyIntroduction,代码行数:16,代码来源:web_browser.py

示例12: WebViewPlus

class WebViewPlus(QWebEngineView):
    """
	WebView 커스터마이징
	 - inspector 추가
	 - jsconsole 로그 추가
	 - webview에서 document로 이벤트를 발생함.
	"""

    def __init__(self):
        super().__init__()
        self.setPage(WebPagePlus())


        #Keyboard shortcuts
        self.shortcut = {}

        #F5 - Page reloading
        self.shortcut['F5'] = QShortcut(self)
        self.shortcut['F5'].setKey(Qt.Key_F5)
        self.shortcut['F5'].activated.connect(self.reload)

    #Devtool setup
    def debuggingMode(self, port):
        #F12 - Development tool
        self.shortcut['F12'] = QShortcut(self)
        self.shortcut['F12'].setContext(Qt.ApplicationShortcut)
        self.shortcut['F12'].setKey(Qt.Key_F12)
        self.shortcut['F12'].activated.connect(self._toggleDevTool)

        self.devTool = QDialog(self)
        self.devTool.setWindowTitle("Development Tool")
        self.devTool.resize(950, 400)

        self.devView = QWebEngineView()
        self.devView.setPage(QWebEnginePage(self.devView))
        
        self.devView.load(QUrl("http://localhost:"+port))
        layout = QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.devView)
        self.devTool.setLayout(layout)

    def _toggleDevTool(self):
        """
        F12키를 다시 누르면 "개발자 도구"가 사라짐
        """
        self.devTool.setVisible(not self.devTool.isVisible())
开发者ID:zipu,项目名称:QWebview-plus,代码行数:47,代码来源:web.py

示例13: MainWidow

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,代码行数:46,代码来源:test.py

示例14: test

def test():
    app = QApplication(sys.argv)
    window = QMainWindow()
    window.setWindowTitle('PyQt Demo')
    window.setGeometry(320, 180, 960, 540)
    webView = QWebEngineView()
    # webView.settings().setAttribute(QWebEngineSettings.)
    # webView.javaScriptConsoleMessage
    # webView.load(QUrl('https://www.baidu.com'))
    webView.load(QUrl('http://192.168.1.217:8088'))
    # webView.load(QUrl('http://192.168.1.217:8088/groundcontrol/test_console.html'))
    # webView.load(QUrl('https://www.raspberrypi.org/'))
    # webView.load(QUrl('http://www.oschina.net'))
    # webView.load(QUrl('https://github.com/'))
    # webView.load(QUrl('http://127.0.0.1:8088'))
    window.setCentralWidget(webView)
    window.show()
    sys.exit(app.exec_())
开发者ID:kamijawa,项目名称:pi_server,代码行数:18,代码来源:test_pyqt5.py

示例15: WebKitFrame

class WebKitFrame(qw.QFrame):

    def __init__(self, url=None, parent=None):
        if use_pyqt5:
            try:
                from PyQt5.QtWebEngineWidgets import QWebEngineView as WebView
            except (ImportError):
                from PyQt5.QtWebKitWidgets import QWebView as WebView

        else:
            from PyQt4.QtWebKit import QWebView as WebView

        qw.QFrame.__init__(self, parent)
        layout = qw.QGridLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        self.setLayout(layout)
        self.web_widget = WebView()
        layout.addWidget(self.web_widget, 0, 0)
        if url:
            self.web_widget.load(qc.QUrl(url))
开发者ID:hvasbath,项目名称:pyrocko,代码行数:21,代码来源:util.py


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