summaryrefslogtreecommitdiff
path: root/silx/gui/dialog/AbstractDataFileDialog.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/dialog/AbstractDataFileDialog.py')
-rw-r--r--silx/gui/dialog/AbstractDataFileDialog.py56
1 files changed, 34 insertions, 22 deletions
diff --git a/silx/gui/dialog/AbstractDataFileDialog.py b/silx/gui/dialog/AbstractDataFileDialog.py
index 40045fe..c660cd7 100644
--- a/silx/gui/dialog/AbstractDataFileDialog.py
+++ b/silx/gui/dialog/AbstractDataFileDialog.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2016 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
@@ -28,29 +28,36 @@ This module contains an :class:`AbstractDataFileDialog`.
__authors__ = ["V. Valls"]
__license__ = "MIT"
-__date__ = "05/03/2018"
+__date__ = "03/12/2018"
import sys
import os
import logging
-import numpy
import functools
+from distutils.version import LooseVersion
+
+import numpy
+import six
+
import silx.io.url
from silx.gui import qt
from silx.gui.hdf5.Hdf5TreeModel import Hdf5TreeModel
from . import utils
-from silx.third_party import six
from .FileTypeComboBox import FileTypeComboBox
-try:
- import fabio
-except ImportError:
- fabio = None
+
+import fabio
_logger = logging.getLogger(__name__)
+DEFAULT_SIDEBAR_URL = True
+"""Set it to false to disable initilializing of the sidebar urls with the
+default Qt list. This could allow to disable a behaviour known to segfault on
+some version of PyQt."""
+
+
class _IconProvider(object):
FileDialogToParentDir = qt.QStyle.SP_CustomBase + 1
@@ -143,14 +150,22 @@ class _SideBar(qt.QListView):
:rtype: List[str]
"""
urls = []
- if qt.qVersion().startswith("5.") and sys.platform in ["linux", "linux2"]:
+ version = LooseVersion(qt.qVersion())
+ feed_sidebar = True
+
+ if not DEFAULT_SIDEBAR_URL:
+ _logger.debug("Skip default sidebar URLs (from setted variable)")
+ feed_sidebar = False
+ elif version.version[0] == 4 and sys.platform in ["win32"]:
+ # Avoid locking the GUI 5min in case of use of network driver
+ _logger.debug("Skip default sidebar URLs (avoid lock when using network drivers)")
+ feed_sidebar = False
+ elif version < LooseVersion("5.11.2") and qt.BINDING == "PyQt5" and sys.platform in ["linux", "linux2"]:
# Avoid segfault on PyQt5 + gtk
_logger.debug("Skip default sidebar URLs (avoid PyQt5 segfault)")
- pass
- elif qt.qVersion().startswith("4.") and sys.platform in ["win32"]:
- # Avoid 5min of locked GUI relative to network driver
- _logger.debug("Skip default sidebar URLs (avoid lock when using network drivers)")
- else:
+ feed_sidebar = False
+
+ if feed_sidebar:
# Get default shortcut
# There is no other way
d = qt.QFileDialog(self)
@@ -1061,8 +1076,6 @@ class AbstractDataFileDialog(qt.QDialog):
def __openFabioFile(self, filename):
self.__closeFile()
try:
- if fabio is None:
- raise ImportError("Fabio module is not available")
self.__fabio = fabio.open(filename)
self.__openedFiles.append(self.__fabio)
self.__selectedFile = filename
@@ -1108,10 +1121,10 @@ class AbstractDataFileDialog(qt.QDialog):
if codec.is_autodetect():
if self.__isSilxHavePriority(filename):
openners.append(self.__openSilxFile)
- if fabio is not None and self._isFabioFilesSupported():
+ if self._isFabioFilesSupported():
openners.append(self.__openFabioFile)
else:
- if fabio is not None and self._isFabioFilesSupported():
+ if self._isFabioFilesSupported():
openners.append(self.__openFabioFile)
openners.append(self.__openSilxFile)
elif codec.is_silx_codec():
@@ -1159,10 +1172,9 @@ class AbstractDataFileDialog(qt.QDialog):
is_fabio_have_priority = not codec.is_silx_codec() and not self.__isSilxHavePriority(path)
if is_fabio_decoder or is_fabio_have_priority:
# Then it's flat frame container
- if fabio is not None:
- self.__openFabioFile(path)
- if self.__fabio is not None:
- selectedData = _FabioData(self.__fabio)
+ self.__openFabioFile(path)
+ if self.__fabio is not None:
+ selectedData = _FabioData(self.__fabio)
else:
assert(False)