From 065f84094167e21397d10114e805e7e35dd73635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Bra=C3=B1a?= Date: Sun, 3 May 2026 00:56:01 +0200 Subject: [PATCH] =?UTF-8?q?Georeferencing:=20import=20QWebEngineView=20mul?= =?UTF-8?q?ti-versi=C3=B3n=20(PySide6=20QtWebEngineCore/Quick=20fallback)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PVPlantGeoreferencing.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/PVPlantGeoreferencing.py b/PVPlantGeoreferencing.py index e5887bc..9a87c55 100644 --- a/PVPlantGeoreferencing.py +++ b/PVPlantGeoreferencing.py @@ -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)