本文整理汇总了Python中PyQt5.QtWebEngineWidgets.QWebEngineView.show方法的典型用法代码示例。如果您正苦于以下问题:Python QWebEngineView.show方法的具体用法?Python QWebEngineView.show怎么用?Python QWebEngineView.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWebEngineWidgets.QWebEngineView
的用法示例。
在下文中一共展示了QWebEngineView.show方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Window
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [as 别名]
class Window(BaseWindow):
def __init__(self):
self.debug=1
self.app = QApplication(sys.argv)
self.desktop= QApplication.desktop()
self.web = QWebEngineView()
self.icon = QIcon(ICON)
#self.web.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
self.web.titleChanged.connect(self.title_changed)
self.web.iconUrlChanged.connect(self.icon_changed)
self.web.page().windowCloseRequested.connect(self.close_window)
self.web.page().geometryChangeRequested.connect(self.set_geometry)
def show(self,window_state):
if window_state == "maximized" and not self.web.isMaximized():
self.web.showNormal()
self.web.showMaximized()
elif window_state == "fullscreen" and not self.web.isFullScreen():
self.web.showNormal()
self.web.showFullScreen()
elif window_state == "normal":
self.web.showNormal()
else:
self.web.show()
def run(self):
return self.app.exec_()
def set_debug(self, debuglevel):
self.debug=debuglevel
def set_geometry(self,geom ):
self.web.setGeometry(geom)
def close_window(self):
sys.exit()
def icon_changed(self):
if not self.icon.isNull():
self.web.setWindowIcon(self.icon)
def title_changed(self, title):
self.web.setWindowTitle(title)
def load_url(self,url):
self.url=QUrl.fromEncoded(url)
self.web.setUrl(self.url)
def set_size(self,width, height):
if width<=0:
width=640
if height<=0:
height=480
left=(self.desktop.width()-width)/2
top=(self.desktop.height()-height)/2
self.web.setGeometry(left,top,width,height)
示例2: mainPyQt5
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [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_())
示例3: MainWidow
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [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
示例4: parse_args
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [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_()
示例5: QApplication
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [as 别名]
from PyQt5.QtOpenGL import QGLWidget
import plots
html = '''<html>
<head>
<title>Plotly Example</title>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
%(plot_content)s
</body>
</html>'''
if __name__ == '__main__':
app = QApplication(sys.argv)
w = QWebView()
w.resize(800, 600)
w.setWindowTitle('Simple Plot')
# QWebSettings.globalSettings().setAttribute(QWebSettings.AcceleratedCompositingEnabled, True)
# QWebSettings.globalSettings().setAttribute(QWebSettings.WebGLEnabled, True)
plot_content = plots.plot3d()
w.setHtml(html%{'plot_content':plot_content})
w.show()
sys.exit(app.exec_())
示例6: run
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [as 别名]
def run(self):
view = QWebEngineView()
view.show()
view.setUrl(QUrl("https://google.com"))
self.app.exec()
示例7: QApplication
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [as 别名]
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
import sys
app = QApplication(sys.argv)
view=QWebEngineView()
view.setUrl(QUrl("https://www.baidu.com/"))
view.show()
app.exec_()
示例8: QWebView
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [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)
示例9: QWebEngineView
# 需要导入模块: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 别名]
# 或者: from PyQt5.QtWebEngineWidgets.QWebEngineView import show [as 别名]
import os
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.Qt import QUrl
from PyQt5 import QtWidgets, QtGui
widget = QWebEngineView()
fake_url = QUrl.fromLocalFile(os.path.abspath("seamless.html"))
widget.setWindowTitle(PINS.title.get().data)
reloadAction = QtWidgets.QAction(QtGui.QIcon('exit.png'), '&Reload', widget)
reloadAction.setShortcut('F5')
reloadAction.setStatusTip('Reload')
reloadAction.triggered.connect(widget.reload)
widget.addAction(reloadAction)
widget.setHtml(PINS.val.get().data, fake_url)
widget.show()