Skip to content

Commit

Permalink
Reading SPEC files as HDF5 files working.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasole committed Apr 9, 2024
1 parent 79bd4dc commit 6410f01
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 4 additions & 2 deletions PyMca5/PyMcaGui/io/QSourceSelector.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def openSource(self, sourcename, specsession=None):
def openFile(self, filename=None, justloaded=None, specsession=False):
_logger.debug("openfile = %s", filename)
staticDialog = False
fileFilter = None
if specsession == "bliss":
specsession = False
session = filename
Expand Down Expand Up @@ -243,11 +244,12 @@ def openFile(self, filename=None, justloaded=None, specsession=False):
"No shared memory source named %s" % key)
return

self._emitSourceSelectedOrReloaded(filename, key)
self._emitSourceSelectedOrReloaded(filename, key, filefilter=fileFilter)

def _emitSourceSelectedOrReloaded(self, filename, key):
def _emitSourceSelectedOrReloaded(self, filename, key, filefilter=None):
ddict = {}
ddict["event"] = "NewSourceSelected"
ddict["filter"] = filefilter
if key in self.mapCombo.keys():
if self.mapCombo[key] == filename:
#Reloaded event
Expand Down
15 changes: 13 additions & 2 deletions PyMca5/PyMcaGui/pymca/QDispatcher.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/*##########################################################################
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
# Copyright (C) 2004-2024 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF.
Expand Down Expand Up @@ -62,6 +62,8 @@ def __init__(self, parent=None, pluginsIcon=False):
"JCAMP-DX Files (*.jdx *.JDX *.dx *.DX)"]
if QDataSource.NEXUS:
fileTypeList.append("HDF5 Files (*.nxs *.hdf *.h5 *.hdf5)")
if "silx" in sys.modules:
fileTypeList.append("HDF5-like Files (*)")
fileTypeList.append("All Files (*)")

self.sourceSelector = QSourceSelector.QSourceSelector(self,
Expand Down Expand Up @@ -250,7 +252,15 @@ def _sourceSelectorSlot(self, ddict):
_logger.debug("_sourceSelectorSlot(self, ddict)")
_logger.debug("ddict = %s", ddict)
if ddict["event"] == "NewSourceSelected":
source = QDataSource.QDataSource(ddict["sourcelist"])
# use the supplied filter in case of HDF5-like (silx)
ffilter = ddict.get("filter", "None")
if ffilter in [None, "None"]:
source_type = None
elif ffilter.startswith("HDF5"):
source_type = QDataSource.NexusDataSource.SOURCE_TYPE
else:
source_type = None
source = QDataSource.QDataSource(ddict["sourcelist"], source_type=source_type)
self.sourceList.append(source)
sourceType = source.sourceType
self.selectorWidget[sourceType].setDataSource(source)
Expand Down Expand Up @@ -373,4 +383,5 @@ def test():
app.exec()

if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
test()

0 comments on commit 6410f01

Please sign in to comment.