PyQT5 (六十三)QWebEngineView 使用Web浏览器控件显示网页 的案例

QWebEngineView 使用Web浏览器控件显示网页 的案例

PyQt5和Web的交互技术
同时使用Python和Web开发程序,混合开发,可以实现任何一种漂亮的UI

Python + JavaScript + HTML5 + CSS

QWebEngineView

import sys

from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QIcon
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QMainWindow, QHBoxLayout, QPushButton, QMessageBox, QApplication


'''
QWebEngineView 使用Web浏览器控件显示网页 的案例

PyQt5和Web的交互技术
同时使用Python和Web开发程序,混合开发,可以实现任何一种漂亮的UI

Python + JavaScript + HTML5 + CSS

QWebEngineView

'''

class WebEngineViewDemo(QMainWindow):

    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        # 设置定位和左上角坐标
        self.setGeometry(300, 300, 360, 260)
        # 设置窗口标题
        self.setWindowTitle('QWebEngineView 使用Web浏览器控件显示网页 的演示')
        # 设置窗口图标
        # self.setWindowIcon(QIcon('../web.ico'))

        self.browser = QWebEngineView()
        self.browser.load(QUrl('http://baidu.com'))
        self.setCentralWidget(self.browser)



if __name__ == '__main__':
    app = QApplication(sys.argv)
    # 设置应用图标
    app.setWindowIcon(QIcon('../web.ico'))
    w = WebEngineViewDemo()
    w.show()
    sys.exit(app.exec_())


版权声明:本文为gixome原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。