Georeferencing: import QWebEngineView multi-versión (PySide6 QtWebEngineCore/Quick fallback)
This commit is contained in:
@@ -58,8 +58,40 @@ class MapWindow(QtGui.QWidget):
|
||||
self.setupUi()
|
||||
|
||||
def setupUi(self):
|
||||
from PySide.QtWebEngineWidgets import QWebEngineView
|
||||
from PySide.QtWebChannel import QWebChannel
|
||||
# Compatibilidad PySide6 / PySide2: QWebEngineView cambia de ubicación
|
||||
QWebEngineView = None
|
||||
QWebChannel = None
|
||||
for modpath in [
|
||||
'PySide6.QtWebEngineWidgets', # Qt6 temprano
|
||||
'PySide6.QtWebEngineCore', # Qt6 reciente: QWebEnginePage aquí
|
||||
'PySide6.QtWebEngineQuick', # Qt6 reciente: QWebEngineView aquí
|
||||
'PySide2.QtWebEngineWidgets', # Qt5
|
||||
'PySide.QtWebEngineWidgets', # Qt5 alias
|
||||
]:
|
||||
try:
|
||||
parts = modpath.split('.')
|
||||
mod = __import__(parts[0], fromlist=parts[1:])
|
||||
for p in parts[1:]:
|
||||
mod = getattr(mod, p)
|
||||
if hasattr(mod, 'QWebEngineView'):
|
||||
QWebEngineView = mod.QWebEngineView
|
||||
if hasattr(mod, 'QWebChannel'):
|
||||
QWebChannel = mod.QWebChannel
|
||||
break
|
||||
except (ImportError, AttributeError):
|
||||
continue
|
||||
|
||||
if QWebEngineView is None:
|
||||
# Fallback: QWebEnginePage + QWebEngineView desde QtWebEngineCore
|
||||
try:
|
||||
from PySide6.QtWebEngineCore import QWebEnginePage
|
||||
from PySide6.QtWebEngineQuick import QWebEngineView
|
||||
QWebEngineView = QWebEngineView
|
||||
except ImportError:
|
||||
FreeCAD.Console.PrintError(
|
||||
"PVPlantGeoreferencing: No se encontró QtWebEngine. "
|
||||
"Instala PySide6-QtWebEngine o usa una versión de FreeCAD con soporte web.\n")
|
||||
return
|
||||
|
||||
self.ui = FreeCADGui.PySideUic.loadUi(PVPlantResources.__dir__ + "/PVPlantGeoreferencing.ui", self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user