"""
用web浏览器控件QWebEngineView显示网页
PyQT5和Web交互技术
使用python和web混合开发
Python + JavaScript + HTML5 + CSS
"""
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle('加载外部网页的例子')
self.setGeometry(5, 30, 1355, 730)
self.browser = QWebEngineView()
# 加载外部的web界面
self.browser.load(QUrl('https://www.baidu.com'))
self.setCentralWidget(self.browser)
if __name__ == '__main__':
app = QApplication(sys.argv)
win = MainWindow()
win.show()
app.exit(app.exec_())