ModelViewer.py 724 B

1234567891011121314151617181920212223
  1. from PyQt5.QtWebEngineWidgets import *
  2. from PyQt5.QtCore import QUrl
  3. from typing import Optional
  4. from PyQt5.QtWebEngineWidgets import QWebEngineView
  5. from PyQt5 import QtCore
  6. QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts)
  7. class ModelWebView(QWebEngineView):
  8. def __init__(
  9. self,
  10. weburi: str,
  11. title: Optional[str] = "自定义窗口",
  12. windowW: Optional[int] = 1200,
  13. windowH: Optional[int] = 800,
  14. ):
  15. super().__init__()
  16. self.uri = weburi
  17. self.resize(windowW, windowH)
  18. self.setWindowTitle(title)
  19. self.page = QWebEnginePage()
  20. self.page.load(QUrl(self.uri))
  21. self.setPage(self.page)