1. PyQt 5.13.0
1.1 安装PyQt
pip install PyQt5==5.13.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
1.2 安装PyQtWebEngine
pip install PyQtWebEngine==5.13.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip list
1.3 测试
python文件
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets 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()
sys.exit(app.exec_())
结果
2. PyQt 5.15.4
2.1 安装PyQt
pip install PyQt5==5.15.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
2.2 安装PyQtWebEngine
pip install PyQtWebEngine==5.13.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip list
2.3 测试
python
import sys
from PyQt5.QtCore import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWidgets 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()
sys.exit(app.exec_())