本文整理汇总了Python中PyQt5.QtWebEngineWidgets.QWebEngineView.load方法的典型用法代码示例。如果您正苦于以下问题:Python QWebEngineView.load方法的具体用法?Python QWebEngineView.load怎么用?Python QWebEngineView.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWebEngineWidgets.QWebEngineView
的用法示例。
在下文中一共展示了QWebEngineView.load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showDocumentation
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
def showDocumentation(self):
if self._documentation is None:
doc = QWebView(self)
doc.load(QUrl("doc/html/index.html"))
self._documentation = QDockWidget("Documentation", self)
self._documentation.setWidget(doc)
self._documentation.closeEvent = lambda _: self.hide_documentation()
self.addDockWidget(Qt.LeftDockWidgetArea, self._documentation)
示例2: test1
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
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_())
示例3: mainPyQt5
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
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_())
示例4: WebViewPlus
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
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())
示例5: test
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
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_())
示例6: WebKitFrame
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
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))
示例7: parse_args
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [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_()
示例8: DrrrWindow
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
class DrrrWindow(ShadowsWindow):
def __init__(self):
super(DrrrWindow, self).__init__()
self.setWindowTitle("Drrr Chat Room")
self.setWindowIcon(QIcon('./img/drrr.ico'))
# w = WebView()
# w.show()
self.getSetting()
self.WebView = QWebEngineView()
# self.WebView.load(QUrl("file:///E:/Project/DrrrPC/img/index.html"))
self.WebView.setZoomFactor(0.8)
# 设置加载网页,和网页加载完成以及加载过程信号与槽函数关联
self.WebView.loadStarted.connect(self.loadStarted)
self.WebView.loadFinished.connect(self.loadFinished)
self.WebView.loadProgress.connect(self.loading)
self.cookieJar = QNetworkCookieJar()
# self.WebView.page().networkAccessManager().setCookieJar(self.cookieJar)
# self.WebView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
# self.WebView.page().linkClicked.connect(self.linkClicked)
# self.WebView.page().contentsChanged.connect(self.contentsChanged)
# self.WebView.page().networkAccessManager().setHeader(QNetworkRequest.ContentTypeHeader, QVariant("text/html; charset=GBK"))
# 重定义QWebEnginePage中javaScriptAlert等函数
self.WebView.page().javaScriptAlert = self._javascript_alert
self.WebView.page().javaScriptConsoleMessage = self._javascript_console_message
self.WebView.page().javaScriptConfirm = self._javascript_confirm
self.WebView.page().javaScriptPrompt = self._javascript_prompt
# NetworkAccessManager
# self.NetworkAccessManager = QNetworkAccessManager()
# self.WebView.page().setNetworkAccessManager(self.NetworkAccessManager)
# self.NetworkAccessManager.finished.connect(self.NetworkAccessManagerReplyFinished)
# self.NetworkAccessManager.get(QNetworkRequest(QUrl("http://www.baidu.com")))
# self.old_manager = self.WebView.page().networkAccessManager()
# self.new_manager = NetworkAccessManager(self.old_manager)
# self.WebView.page().setNetworkAccessManager(self.new_manager)
self.titlebar = titleBar()
self.statusBar = StatusWindow()
# 中心窗口布局
self.contentLayout = QVBoxLayout()
self.contentWidget = QWidget()
self.contentWidget.gridLayout = QtWidgets.QGridLayout(self.contentWidget)
self.contentWidget.gridLayout.addLayout(self.contentLayout, 0, 0, 1, 1)
self.contentLayout.addWidget(self.WebView)
self.contentWidget.gridLayout.setContentsMargins(0,0,0,0)
self.contentLayout.setContentsMargins(1,0,1,0)
self.contentWidget.setStyleSheet("""
border-left: 1px solid black;
border-right: 1px solid black;
""")
# self.titlebar.titlebarBotton = QPushButton(self.titlebar)
# self.titlebar.titlebarBotton.setText('Push ME')
# self.titlebar.titlebarBotton.clicked.connect(self.getData)
self.main_layout = QVBoxLayout()
self.main_layout.addWidget(self.titlebar)
self.main_layout.addWidget(self.contentWidget)
self.main_layout.addWidget(self.statusBar)
self.main_layout.setSpacing(0)
# 窗口属性
self.setWindowFlags(Qt.Widget | QtCore.Qt.FramelessWindowHint)
self.setAttribute(Qt.WA_NoSystemBackground, True)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground,True)
self.widget = QWidget()
self.setCentralWidget(self.widget)
self.widget.setLayout(self.main_layout)
self.widget.setMouseTracking(True)
# self.resize(500,650)
self.resize(650,650)
# self.setMaximumHeight(660)
self.center()
# 将三个按钮点击信号与相关槽函数相关联
self.titlebar.min_button.clicked.connect(self.hideIt)
self.titlebar.max_button.clicked.connect(self.MaxAndNormal)
self.titlebar.close_button.clicked.connect(self.closeIt)
# 状态栏进度条:将LoadProgress信号与loading槽函数相关联
self.WebView.loadProgress.connect(self.loading)
# notice sound
# self.player =
self.WebView.setHtml(WaitingHTML)
self.show()
self.WebView.setStyleSheet("""
QWebView {
background-color:black
}
#.........这里部分代码省略.........
示例9: QApplication
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
QWebView with URL
"""
import sys
from PyQt5.QtWidgets import QApplication, QWidget
#from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWebEngineWidgets import QWebEngineView as QWebView
from PyQt5.QtCore import QUrl
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWebView()
w.resize(800, 600)
w.move(300, 300)
w.setWindowTitle('Simple Plot')
w.load(QUrl("http://google.com/"));
w.show()
sys.exit(app.exec_())
示例10: QApplication
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
from PyQt5.QtWebChannel import QWebChannel
import sys
# 创建一个 application实例
app = QApplication(sys.argv)
win = QWidget()
win.setWindowTitle('Web页面中的JavaScript与 QWebEngineView交互例子')
# 创建一个垂直布局器
layout = QVBoxLayout()
win.setLayout(layout)
# 创建一个 QWebEngineView 对象
view = QWebEngineView()
htmlUrl = 'http://127.0.0.1:8020/web/index.html'
view.load( QUrl( htmlUrl ))
# 创建一个 QWebChannel对象,用来传递pyqt参数到JavaScript
channel = QWebChannel( )
myObj = MySharedObject()
channel.registerObject( "bridge", myObj )
view.page().setWebChannel(channel)
# 把QWebView和button加载到layout布局中
layout.addWidget(view)
# 显示窗口和运行app
win.show()
sys.exit(app.exec_())
示例11: QWebView
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# See http://doc.qt.io/qt-5/qwebengineview.html#details
# This class replace the deprecated QWebView (based on QtWebKit).
# See:
# - https://stackoverflow.com/questions/29055475/qwebview-or-qwebengineview
# - https://wiki.qt.io/QtWebEngine/Porting_from_QtWebKit
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
web = QWebEngineView()
web.load(QUrl("http://www.jdhp.org"))
web.show()
# The mainloop of the application. The event handling starts from this point.
# The exec_() method has an underscore. It is because the exec is a Python keyword. And thus, exec_() was used instead.
exit_code = app.exec_()
# The sys.exit() method ensures a clean exit.
# The environment will be informed, how the application ended.
sys.exit(exit_code)
示例12: QApplication
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
import sys
if __name__ == '__main__':
app = QApplication(sys.argv)
view = QWebEngineView()
view.load(QUrl('https://www.baidu.com'))
view.show()
sys.exit(app.exec_())
示例13: MainWindow
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import load [as 别名]
class MainWindow(QMainWindow):
"""Main window class."""
def __init__(self):
"""Init class."""
super(MainWindow, self).__init__()
self.pixmap_syncthingui = QPixmap(":/images/syncthingui.svg")
tf = QTransform()
self.pixmap_syncthingui0 = QPixmap(":/images/syncthingui.svg")
tf.rotate(90.0)
self.pixmap_syncthingui1 = self.pixmap_syncthingui0.transformed(tf)
tf.rotate(180.0)
self.pixmap_syncthingui2 = self.pixmap_syncthingui0.transformed(tf)
tf.rotate(270.0)
self.pixmap_syncthingui3 = self.pixmap_syncthingui0.transformed(tf)
self.init_gui()
self.init_menu()
self.init_systray()
self.run()
def init_gui(self):
"""init gui setup"""
self.setWindowIcon(QIcon(self.pixmap_syncthingui))
self.progressbar = QProgressBar()
self.statusBar().showMessage(getoutput(SYNCTHING + ' --version'))
self.statusBar().addPermanentWidget(self.progressbar)
self.setWindowTitle(__doc__.strip().capitalize())
self.setMinimumSize(900, 600)
self.setMaximumSize(1280, 1024)
self.resize(self.minimumSize())
self.center()
# QWebView
# self.view = QWebView(self)
self.view = QWebEngineView(self)
self.view.loadStarted.connect(self.start_loading)
self.view.loadFinished.connect(self.finish_loading)
self.view.loadProgress.connect(self.loading)
self.view.titleChanged.connect(self.set_title)
self.view.page().linkHovered.connect(
lambda link_txt: self.statusBar().showMessage(link_txt[:99], 3000))
QShortcut("Ctrl++", self, activated=lambda:
self.view.setZoomFactor(self.view.zoomFactor() + 0.2))
QShortcut("Ctrl+-", self, activated=lambda:
self.view.setZoomFactor(self.view.zoomFactor() - 0.2))
QShortcut("Ctrl+0", self, activated=lambda: self.view.setZoomFactor(1))
QShortcut("Ctrl+q", self, activated=lambda: self.close())
# syncthing console
self.consolewidget = QWidget(self)
# TODO: start at specify (w,h)
self.consolewidget.setMinimumSize(QSize(200, 100))
# TODO: setStyleSheet
# self.consolewidget.setStyleSheet("margin:0px; padding: 0px; \
# border:1px solid rgb(0, 0, 0);")
# border-radius: 40px;")
# TODO read syncthing console visible from setting
# self.consolewidget.setVisible(False)
# self.consolewidget.showEvent
# self.consoletextedit = QPlainTextEdit(parent=self.consolewidget)
self.consoletoolbar = QWidget(self)
hlayout = QHBoxLayout()
hlayout
self.consoletoolbar.setLayout(hlayout)
self.consoletextedit = QTextEdit(parent=self.consolewidget)
self.consoletextedit.setWordWrapMode(QTextOption.NoWrap)
# self.consoletextedit.setStyleSheet(" border:1px solid rgb(0, 0, 0);")
# self.consoletextedit.setStyleSheet("margin:0px; padding: 0px;")
layout = QVBoxLayout()
layout.addWidget(self.consoletoolbar)
layout.addWidget(self.consoletextedit)
self.consolewidget.setLayout(layout)
self.splitter = QSplitter(Qt.Vertical)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.consolewidget)
# process
self.process = QProcess()
self.process.error.connect(self._process_failed)
# QProcess emits `readyRead` when there is data to be read
self.process.readyRead.connect(self._process_dataReady)
self.process.stateChanged.connect(self._process_stateChanged)
# Just to prevent accidentally running multiple times
# Disable the button when process starts, and enable it when it finishes
# self.process.started.connect(lambda: self.runButton.setEnabled(False))
# self.process.finished.connect(lambda: self.runButton.setEnabled(True))
# backend options
self.chrt = QCheckBox("Smooth CPU ", checked=True)
self.ionice = QCheckBox("Smooth HDD ", checked=True)
self.chrt.setToolTip("Use Smooth CPUs priority (recommended)")
self.ionice.setToolTip("Use Smooth HDDs priority (recommended)")
self.chrt.setStatusTip(self.chrt.toolTip())
self.ionice.setStatusTip(self.ionice.toolTip())
#.........这里部分代码省略.........