From d79efcddf7c7a0bc56c4cba2ae34f88c68a006a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=2E=20Armando=20Sol=C3=A9?= Date: Tue, 7 Nov 2023 18:25:44 +0100 Subject: [PATCH 1/2] Add compatibility with silx 2 --- .../PyMcaGui/plotting/SilxMaskImageWidget.py | 6 ++- PyMca5/PyMcaGui/plotting/SilxPlotActions.py | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 PyMca5/PyMcaGui/plotting/SilxPlotActions.py diff --git a/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py b/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py index a61a9d05e..39c49d05f 100644 --- a/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py +++ b/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py @@ -65,7 +65,11 @@ import silx from silx.gui.plot import PlotWidget -from silx.gui.plot import PlotActions +try: + from silx.gui.plot import PlotActions +except ImportError: + from PyMca5.PyMcaGui.plotting import SilxPlotActions as PlotActions + from silx.gui.plot import PlotToolButtons from silx.gui.plot.MaskToolsWidget import MaskToolsWidget, MaskToolsDockWidget from silx.gui.plot.AlphaSlider import NamedImageAlphaSlider diff --git a/PyMca5/PyMcaGui/plotting/SilxPlotActions.py b/PyMca5/PyMcaGui/plotting/SilxPlotActions.py new file mode 100644 index 000000000..9bcb72995 --- /dev/null +++ b/PyMca5/PyMcaGui/plotting/SilxPlotActions.py @@ -0,0 +1,37 @@ +#/*########################################################################## +# Copyright (C) 2023 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 +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# +#############################################################################*/ +__author__ = "V.A. Sole - ESRF Data Analysis" +__contact__ = "sole@esrf.fr" +__license__ = "MIT" +__copyright__ = "European Synchrotron Radiation Facility, Grenoble, France" + +__doc__ = """Silx 1.x and 2.x compatibility layer""" + +try: + from silx.gui.plot.PlotActions import * +except ImportError: + from silx.gui.plot.actions.control import * + from silx.gui.plot.actions.io import * + from silx.gui.plot.actions.histogram import PixelIntensitiesHistoAction + + From e7c0ff53e12a0ee0302385e076525bd9fb4f05d6 Mon Sep 17 00:00:00 2001 From: "V. Armando Sole" Date: Fri, 10 Nov 2023 10:19:07 +0100 Subject: [PATCH 2/2] Import from a single place. --- PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py | 5 +---- PyMca5/PyMcaGui/plotting/SilxPlotActions.py | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py b/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py index 39c49d05f..4d6173cf2 100644 --- a/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py +++ b/PyMca5/PyMcaGui/plotting/SilxMaskImageWidget.py @@ -65,10 +65,7 @@ import silx from silx.gui.plot import PlotWidget -try: - from silx.gui.plot import PlotActions -except ImportError: - from PyMca5.PyMcaGui.plotting import SilxPlotActions as PlotActions +from PyMca5.PyMcaGui.plotting import SilxPlotActions as PlotActions from silx.gui.plot import PlotToolButtons from silx.gui.plot.MaskToolsWidget import MaskToolsWidget, MaskToolsDockWidget diff --git a/PyMca5/PyMcaGui/plotting/SilxPlotActions.py b/PyMca5/PyMcaGui/plotting/SilxPlotActions.py index 9bcb72995..b3c765086 100644 --- a/PyMca5/PyMcaGui/plotting/SilxPlotActions.py +++ b/PyMca5/PyMcaGui/plotting/SilxPlotActions.py @@ -33,5 +33,3 @@ from silx.gui.plot.actions.control import * from silx.gui.plot.actions.io import * from silx.gui.plot.actions.histogram import PixelIntensitiesHistoAction - -