From 086673b2346ce4e0a8a8b36b713ad4b21bd73b38 Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Tue, 19 Feb 2019 14:45:58 +0100 Subject: [PATCH 1/3] Fix result --- silx/gui/data/DataViews.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/silx/gui/data/DataViews.py b/silx/gui/data/DataViews.py index 398c4e1ae3..83835894e3 100644 --- a/silx/gui/data/DataViews.py +++ b/silx/gui/data/DataViews.py @@ -42,7 +42,7 @@ __authors__ = ["V. Valls", "P. Knobel"] __license__ = "MIT" -__date__ = "15/02/2019" +__date__ = "19/02/2019" _logger = logging.getLogger(__name__) @@ -754,6 +754,7 @@ def replaceView(self, modeId, newView): # replace oldView with new view in dict self.__views[iview] = newView + return True class _EmptyView(DataView): From 2cfdd37b4c8b48bf11c399f43444ec333be997fd Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Tue, 19 Feb 2019 14:46:20 +0100 Subject: [PATCH 2/3] Do not use _NXdataVolumeView if not available --- silx/gui/data/DataViews.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/silx/gui/data/DataViews.py b/silx/gui/data/DataViews.py index 83835894e3..6575d0d4f0 100644 --- a/silx/gui/data/DataViews.py +++ b/silx/gui/data/DataViews.py @@ -1823,5 +1823,9 @@ def __init__(self, parent): nx3dViews = SelectManyDataView(parent) nx3dViews.addView(_NXdataVolumeAsStackView(parent)) nx3dViews.addView(_NXdataComplexVolumeAsStackView(parent)) - nx3dViews.addView(_NXdataVolumeView(parent)) + try: + nx3dViews.addView(_NXdataVolumeView(parent)) + except Exception: + _logger.warning("NXdataVolumeView is not available") + _logger.debug("Backtrace", exc_info=True) self.addView(nx3dViews) From 30e9d4016163c68139dc4bfb10de4c24bebe197e Mon Sep 17 00:00:00 2001 From: Valentin Valls Date: Tue, 19 Feb 2019 14:46:35 +0100 Subject: [PATCH 3/3] Test replaceView result --- silx/gui/data/test/test_dataviewer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/silx/gui/data/test/test_dataviewer.py b/silx/gui/data/test/test_dataviewer.py index 4a3962a0b7..dc6fee817d 100644 --- a/silx/gui/data/test/test_dataviewer.py +++ b/silx/gui/data/test/test_dataviewer.py @@ -24,7 +24,7 @@ # ###########################################################################*/ __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "23/04/2018" +__date__ = "19/02/2019" import os import tempfile @@ -237,8 +237,9 @@ def test_replace_view_in_composite(self): # replace a view that is a child of a composite view widget = self.create_widget() view = _DataViewMock(widget) - widget.replaceView(DataViews.NXDATA_INVALID_MODE, - view) + replaced = widget.replaceView(DataViews.NXDATA_INVALID_MODE, + view) + self.assertTrue(replaced) nxdata_view = widget.getViewFromModeId(DataViews.NXDATA_MODE) self.assertNotIn(DataViews.NXDATA_INVALID_MODE, [v.modeId() for v in nxdata_view.availableViews()])