From e0e36141d6cb2bd4cdb3bcf1282cc57731c42518 Mon Sep 17 00:00:00 2001 From: Marie Spitoni Date: Tue, 26 Nov 2024 17:36:12 +0100 Subject: [PATCH] Motor positions only at the Nxentry level --- src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py | 12 +++++++++--- src/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py | 3 ++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py b/src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py index 65d0d5ab9..5d283b67a 100644 --- a/src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py +++ b/src/PyMca5/PyMcaGui/io/hdf5/NexusInfo.py @@ -65,14 +65,20 @@ def _setInfoDict(self, ddict): class NexusInfoWidget(HDF5Info.HDF5InfoWidget): + def __init__(self, parent=None, info=None, nxclass=None): + self._nxclass = nxclass + super().__init__(parent=parent, info=info) + def _build(self): super()._build() - self.motorInfoWidget = NexusMotorInfoWidget(self) - self.addTab(self.motorInfoWidget, "Motors") + if self._nxclass in ("NXentry", b"NXentry"): + self.motorInfoWidget = NexusMotorInfoWidget(self) + self.addTab(self.motorInfoWidget, "Motors") def setInfoDict(self, ddict): super().setInfoDict(ddict) - self.motorInfoWidget.setInfoDict(ddict) + if self._nxclass in ("NXentry", b"NXentry"): + self.motorInfoWidget.setInfoDict(ddict) def getInfo(hdf5File, node): diff --git a/src/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py b/src/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py index 1961a434b..66af2bc53 100644 --- a/src/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py +++ b/src/PyMca5/PyMcaGui/io/hdf5/QNexusWidget.py @@ -509,7 +509,8 @@ def showInfoWidget(self, filename, name, dset=False): phynxFile = HDF5Widget.h5open(filename) info = self.getInfo(phynxFile, name) - widget = NexusInfo.NexusInfoWidget() + nxclass = phynxFile[name].attrs.get("NX_class") + widget = NexusInfo.NexusInfoWidget(nxclass=nxclass) widget.notifyCloseEventToWidget(self) title = os.path.basename(filename) title += " %s" % name