from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage from typing import Optional from PyQt5.QtCore import QUrl from PyQt5 import QtCore QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) class ModelWebView(QWebEngineView): def __init__( self, weburi: str, title: Optional[str] = "自定义窗口", windowW: Optional[int] = 1200, windowH: Optional[int] = 800, ): super().__init__() self.uri = weburi self.resize(windowW, windowH) self.setWindowTitle(title) self.page = QWebEnginePage() self.page.load(QUrl(self.uri)) self.setPage(self.page)