PyQt5和Web的交互(QWebEngineView)
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
import sys
class WebEngineView(QMainWindow):
def __init__(self ):
super(WebEngineView, self).__init__()
self.setWindowTitle('网页浏览器')
self.setGeometry(5, 30, 1355, 730)
self.browser = QWebEngineView()
# self.browser.load(QUrl('http://www.baidu.com')) 打开外部链接
self.browser.load(QUrl(QFileInfo(r'C:\Users\PycharmProjects\render.html').absoluteFilePath())) # 打开本地Html网页
self.setCentralWidget(self.browser)
if __name__ == '__main__':
app = QApplication(sys.argv)
win = WebEngineView()
win.show()
sys.exit(app.exec_())
配合PYECHARTS生成的HTML图表效果: