summaryrefslogtreecommitdiff
path: root/silx/app/view.py
diff options
context:
space:
mode:
authorPicca Frédéric-Emmanuel <picca@debian.org>2018-03-04 10:20:27 +0100
committerPicca Frédéric-Emmanuel <picca@debian.org>2018-03-04 10:20:27 +0100
commit270d5ddc31c26b62379e3caa9044dd75ccc71847 (patch)
tree55c5bfc851dfce7172d335cd2405b214323e3caf /silx/app/view.py
parente19c96eff0c310c06c4f268c8b80cb33bd08996f (diff)
New upstream version 0.7.0+dfsg
Diffstat (limited to 'silx/app/view.py')
-rw-r--r--silx/app/view.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/silx/app/view.py b/silx/app/view.py
index e8507f4..bc4e30c 100644
--- a/silx/app/view.py
+++ b/silx/app/view.py
@@ -1,6 +1,6 @@
# coding: utf-8
# /*##########################################################################
-# Copyright (C) 2016-2017 European Synchrotron Radiation Facility
+# Copyright (C) 2016-2018 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -25,7 +25,7 @@
__authors__ = ["V. Valls"]
__license__ = "MIT"
-__date__ = "02/10/2017"
+__date__ = "28/02/2018"
import sys
import os
@@ -36,6 +36,17 @@ import collections
_logger = logging.getLogger(__name__)
"""Module logger"""
+if "silx.gui.qt" not in sys.modules:
+ # Try first PyQt5 and not the priority imposed by silx.gui.qt.
+ # To avoid problem with unittests we only do it if silx.gui.qt is not
+ # yet loaded.
+ # TODO: Can be removed for silx 0.8, as it should be the default binding
+ # of the silx library.
+ try:
+ import PyQt5.QtCore
+ except ImportError:
+ pass
+
from silx.gui import qt
@@ -142,22 +153,28 @@ class Viewer(qt.QMainWindow):
dialog.setWindowTitle("Open")
dialog.setModal(True)
+ # NOTE: hdf5plugin have to be loaded before
+ import silx.io
extensions = collections.OrderedDict()
- # expect h5py
- extensions["HDF5 files"] = "*.h5 *.hdf"
- extensions["NeXus files"] = "*.nx *.nxs *.h5 *.hdf"
- # no dependancy
- extensions["NeXus layout from spec files"] = "*.dat *.spec *.mca"
- extensions["Numpy binary files"] = "*.npz *.npy"
- # expect fabio
- extensions["NeXus layout from raster images"] = "*.edf *.tif *.tiff *.cbf *.mccd"
- extensions["NeXus layout from EDF files"] = "*.edf"
- extensions["NeXus layout from TIFF image files"] = "*.tif *.tiff"
- extensions["NeXus layout from CBF files"] = "*.cbf"
- extensions["NeXus layout from MarCCD image files"] = "*.mccd"
+ for description, ext in silx.io.supported_extensions().items():
+ extensions[description] = " ".join(sorted(list(ext)))
+
+ # NOTE: hdf5plugin have to be loaded before
+ import fabio
+ if fabio is not None:
+ extensions["NeXus layout from EDF files"] = "*.edf"
+ extensions["NeXus layout from TIFF image files"] = "*.tif *.tiff"
+ extensions["NeXus layout from CBF files"] = "*.cbf"
+ extensions["NeXus layout from MarCCD image files"] = "*.mccd"
+
+ all_supported_extensions = set()
+ for name, exts in extensions.items():
+ exts = exts.split(" ")
+ all_supported_extensions.update(exts)
+ all_supported_extensions = sorted(list(all_supported_extensions))
filters = []
- filters.append("All supported files (%s)" % " ".join(extensions.values()))
+ filters.append("All supported files (%s)" % " ".join(all_supported_extensions))
for name, extension in extensions.items():
filters.append("%s (%s)" % (name, extension))
filters.append("All files (*)")
@@ -194,7 +211,7 @@ class Viewer(qt.QMainWindow):
selectedObjects = event.source().selectedH5Nodes(ignoreBrokenLinks=False)
menu = event.menu()
- if len(menu.children()):
+ if not menu.isEmpty():
menu.addSeparator()
# Import it here to be sure to use the right logging level
@@ -280,6 +297,7 @@ def main(argv):
sys.excepthook = qt.exceptionHandler
window = Viewer()
+ window.setAttribute(qt.Qt.WA_DeleteOnClose, True)
window.resize(qt.QSize(640, 480))
for filename in options.files: