本文整理匯總了Python中PyQt5.QtWebEngineWidgets.QWebEngineView方法的典型用法代碼示例。如果您正苦於以下問題:Python QtWebEngineWidgets.QWebEngineView方法的具體用法?Python QtWebEngineWidgets.QWebEngineView怎麽用?Python QtWebEngineWidgets.QWebEngineView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWebEngineWidgets
的用法示例。
在下文中一共展示了QtWebEngineWidgets.QWebEngineView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: mainPyQt5
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [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_())
示例2: openWebUI
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def openWebUI(self):
if self.device and self.device.p.get('IPAddress'):
url = QUrl("http://{}".format(self.device.p['IPAddress']))
try:
webui = QWebEngineView()
webui.load(url)
frm_webui = QFrame()
frm_webui.setWindowTitle("WebUI [{}]".format(self.device.p['FriendlyName1']))
frm_webui.setFrameShape(QFrame.StyledPanel)
frm_webui.setLayout(VLayout(0))
frm_webui.layout().addWidget(webui)
frm_webui.destroyed.connect(self.updateMDI)
self.mdi.addSubWindow(frm_webui)
self.mdi.setViewMode(QMdiArea.TabbedView)
frm_webui.setWindowState(Qt.WindowMaximized)
except NameError:
QDesktopServices.openUrl(QUrl("http://{}".format(self.device.p['IPAddress'])))
示例3: imprimirReciboPag
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def imprimirReciboPag(self):
self.documento = QWebEngineView()
self.renderTemplate(
"recibopagamento.html",
estilo=self.resourcepath('Template/estilo.css'),
cod=self.tx_Cod.text(),
descricao=self.tx_descricao.text(),
valor=self.tx_valor.text().replace('.', ','),
valor_ext=retorno(self.tx_valor.text()),
data=date.today().strftime("%d-%m-%Y")
)
self.documento.load(QUrl.fromLocalFile(
self.resourcepath("report.html")))
self.documento.loadFinished['bool'].connect(self.previaImpressao)
示例4: setupUi
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def setupUi(self, LoginWindow):
LoginWindow.setObjectName("LoginWindow")
LoginWindow.resize(501, 425)
self.centralwidget = QtWidgets.QWidget(LoginWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.webEngineView = QtWebEngineWidgets.QWebEngineView(self.centralwidget)
self.webEngineView.setUrl(QtCore.QUrl("https://www.yiban.cn/"))
self.webEngineView.setZoomFactor(1.5)
self.webEngineView.setObjectName("webEngineView")
self.gridLayout.addWidget(self.webEngineView, 0, 0, 1, 1)
LoginWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(LoginWindow)
QtCore.QMetaObject.connectSlotsByName(LoginWindow)
示例5: popupBrowser
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def popupBrowser(self):
w = QDialog(self)
w.resize(600, 500)
w.setWindowTitle('Wiki')
web = QWebEngineView(w)
web.load(QUrl('https://github.com/aerospaceresearch/visma/wiki'))
web.resize(600, 500)
web.show()
w.show()
示例6: createWindow
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def createWindow(self,
wintype: QWebEnginePage.WebWindowType) -> QWebEngineView:
"""Called by Qt when a page wants to create a new tab or window.
In case the user wants to open a resource in a new tab, we use the
createWindow handling of the main page to achieve that.
See WebEngineView.createWindow for details.
"""
return self.page().inspectedPage().view().createWindow(wintype)
示例7: __init__
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# 設置窗口標題
# self.setWindowTitle('My Browser')
# 設置窗口圖標
# self.setWindowIcon(QIcon('icons/penguin.png'))
# 設置窗口大小900*600
# self.resize(900, 600)
# self.show()
# 2
self.view = QWebEngineView()
channel = QWebChannel()
handler = CallHandler()
channel.registerObject('handler', handler)
self.view.page().setWebChannel(channel)
self.view.loadFinished.connect(self._loadFinish)
# 添加瀏覽器到窗口中
# self.setCentralWidget(self.view)
#
htmlUrl = 'file:////Users/play/github/Python_Master_Courses/GUI圖形界麵/pyqt5/pyqt5-javascript-互相傳值/js1.html'
self.view.load(QUrl(htmlUrl))
self.view.show()
# 3
示例8: __init__
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def __init__(self, *args, **kw):
url = kw.pop('url', None)
first = False
if not url:
url = get_authenticated_url()
first = True
self.url = url
self.closing = False
super(QWebView, self).__init__(*args, **kw)
self.setWindowTitle('Bitmask')
self.bitmask_browser = NewPageConnector(self) if first else None
self.loadPage(self.url)
self.bridge = AppBridge(self) if first else None
if self.bridge is not None and HAS_WEBENGINE:
print "[+] registering python<->js bridge"
channel = QWebChannel(self)
channel.registerObject("bitmaskApp", self.bridge)
self.page().setWebChannel(channel)
icon = QtGui.QIcon()
icon.addPixmap(
QtGui.QPixmap(":/mask-icon.png"),
QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.setWindowIcon(icon)
示例9: _stockInfoAct
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def _stockInfoAct(self):
code, name = self._interface.getCodeName()
if code is None: return
browser = DyWebView()
url = 'http://basic.10jqka.com.cn/32/{0}/'.format(code[:-3])
browser.load(QUrl(url))
browser.setWindowTitle(name)
rect = QApplication.desktop().availableGeometry()
taskBarHeight = QApplication.desktop().height() - rect.height()
browser.resize(rect.width()//3 * 2, rect.height() - taskBarHeight)
browser.move((rect.width() - browser.width())//2, 0)
browser.show()
self._browsers.append(browser)
示例10: __init__
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.DomainCookies = {}
self.setWindowTitle('微信讀書助手') # 設置窗口標題
self.resize(900, 600) # 設置窗口大小
self.setWindowFlags(Qt.WindowMinimizeButtonHint) # 禁止最大化按鈕
self.setFixedSize(self.width(), self.height()) # 禁止調整窗口大小
url = 'https://weread.qq.com/#login' # 目標地址
self.browser = QWebEngineView() # 實例化瀏覽器對象
self.profile = QWebEngineProfile.defaultProfile()
self.profile.cookieStore().deleteAllCookies() # 初次運行軟件時刪除所有cookies
self.profile.cookieStore().cookieAdded.connect(self.onCookieAdd) # cookies增加時觸發self.onCookieAdd()函數
self.browser.loadFinished.connect(self.onLoadFinished) # 網頁加載完畢時觸發self.onLoadFinished()函數
self.browser.load(QUrl(url)) # 加載網頁
self.setCentralWidget(self.browser) # 設置中心窗口
# 網頁加載完畢事件
示例11: setupUi
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(563, 339)
self.widget = QWebEngineView(Dialog)
self.widget.setGeometry(QtCore.QRect(10, 60, 531, 251))
self.widget.setObjectName("widget")
self.pushButtonGo = QtWidgets.QPushButton(Dialog)
self.pushButtonGo.setGeometry(QtCore.QRect(450, 20, 91, 23))
font = QtGui.QFont()
font.setPointSize(12)
self.pushButtonGo.setFont(font)
self.pushButtonGo.setObjectName("pushButtonGo")
self.lineEditURL = QtWidgets.QLineEdit(Dialog)
self.lineEditURL.setGeometry(QtCore.QRect(100, 20, 331, 21))
font = QtGui.QFont()
font.setPointSize(12)
self.lineEditURL.setFont(font)
self.lineEditURL.setObjectName("lineEditURL")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(10, 20, 71, 16))
font = QtGui.QFont()
font.setPointSize(12)
self.label.setFont(font)
self.label.setObjectName("label")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
示例12: init_gui
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def init_gui(application, port=0, width=800, height=600,
window_title="PyFladesk", icon="appicon.png", argv=None):
if argv is None:
argv = sys.argv
if port == 0:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(('localhost', 0))
port = sock.getsockname()[1]
sock.close()
# Application Level
qtapp = QtWidgets.QApplication(argv)
webapp = ApplicationThread(application, port)
webapp.start()
qtapp.aboutToQuit.connect(webapp.terminate)
# Main Window Level
window = QtWidgets.QMainWindow()
window.resize(width, height)
window.setWindowTitle(window_title)
window.setWindowIcon(QtGui.QIcon(icon))
# WebView Level
webView = QtWebEngineWidgets.QWebEngineView(window)
window.setCentralWidget(webView)
# WebPage Level
page = WebPage('http://localhost:{}'.format(port))
page.home()
webView.setPage(page)
window.show()
return qtapp.exec_()
示例13: add_tab
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def add_tab(self, *args):
webview = qtwe.QWebEngineView()
tab_index = self.tabs.addTab(webview, 'New Tab')
webview.urlChanged.connect(
lambda x: self.tabs.setTabText(tab_index, x.toString()))
webview.urlChanged.connect(
lambda x: self.urlbar.setText(x.toString()))
# make it so pop-up windows call this method
webview.createWindow = self.add_tab
# History
webview.urlChanged.connect(self.update_history)
# Profile
page = qtwe.QWebEnginePage(self.profile)
webview.setPage(page)
# Add the finder script
page.scripts().insert(self.finder_script)
# set default content
webview.setHtml(
'<h1>Blank Tab</h1><p>It is a blank tab!</p>',
qtc.QUrl('about:blank'))
return webview
示例14: __init__
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.resize(1280, 720)
self.browser = QWebEngineView()
self.setCentralWidget(self.browser)
示例15: python_to_js
# 需要導入模塊: from PyQt5 import QtWebEngineWidgets [as 別名]
# 或者: from PyQt5.QtWebEngineWidgets import QWebEngineView [as 別名]
def python_to_js(page_or_tab, name, *args):
page = page_or_tab.page() if isinstance(page_or_tab, QWebEngineView) else page_or_tab
page.runJavaScript('window.send_message_to_javascript(%s, %s)' % (json.dumps(name), json.dumps(args)), QWebEngineScript.ApplicationWorld)