Skip to content

Commit bc8d899

Browse files
authored
Merge pull request #1133 from silx-kit/vasole-patch-1-1
[GUI] Synchronize with latest silx
2 parents 55edcec + 27595e7 commit bc8d899

2 files changed

Lines changed: 34 additions & 27 deletions

File tree

src/PyMca5/PyMcaGui/io/hdf5/Hdf5NodeView.py

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#/*##########################################################################
2-
# Copyright (C) 2004-2022 European Synchrotron Radiation Facility
2+
# Copyright (C) 2004-2025 European Synchrotron Radiation Facility
33
#
44
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
55
# the ESRF.
@@ -94,36 +94,21 @@ class Plot1DViewWithPlugins(DataViews._Plot1dView):
9494
def createWidget(self, parent):
9595
return Plot1DWithPlugins(parent=parent)
9696

97-
98-
class Plot2DWithPlugins(Plot2D):
99-
"""Add a plugin toolbutton to a Plot2D"""
100-
def __init__(self, parent=None):
101-
Plot2D.__init__(self, parent)
102-
103-
self._toolbar = qt.QToolBar(self)
104-
self.addToolBar(self._toolbar)
105-
pluginsToolButton = PluginsToolButton(plot=self, parent=self,
97+
class Plot2DViewWithPlugins(DataViews._Plot2dView):
98+
def createWidget(self, parent):
99+
widget = super().createWidget(parent)
100+
widget.setKeepDataAspectRatio(False)
101+
pymcaToolbar = qt.QToolBar(widget)
102+
widget.addToolBar(pymcaToolbar)
103+
pluginsToolButton = PluginsToolButton(plot=widget, parent=widget,
106104
method="getPlugin2DInstance")
107105

108106
if PLUGINS_DIR:
109107
pluginsToolButton.getPlugins(
110108
method="getPlugin2DInstance",
111109
directoryList=PLUGINS_DIR)
112-
self._toolbar.addWidget(pluginsToolButton)
113-
if hasattr(self, "getIntensityHistogramAction"):
114-
self.getIntensityHistogramAction().setVisible(True)
115-
else:
116-
print("Plot2D getIntensityHistogramAction missing")
117-
118-
119-
class Plot2DViewWithPlugins(DataViews._Plot2dView):
120-
def createWidget(self, parent):
121-
widget = Plot2DWithPlugins(parent=parent)
122-
widget.setDefaultColormap(self.defaultColormap())
123-
widget.getColormapAction().setColorDialog(self.defaultColorDialog())
124-
widget.setKeepDataAspectRatio(False)
125-
widget.getXAxis().setLabel('X')
126-
widget.getYAxis().setLabel('Y')
110+
pymcaToolbar.addWidget(pluginsToolButton)
111+
widget.getIntensityHistogramAction().setVisible(True)
127112
return widget
128113

129114
class ArrayCurvePlotWithPlugins(NXdataWidgets.ArrayCurvePlot):

src/PyMca5/tests/WidgetsInstantiationTest.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#/*##########################################################################
2-
# Copyright (C) 2004-2023 European Synchrotron Radiation Facility
2+
# Copyright (C) 2004-2025 European Synchrotron Radiation Facility
33
#
44
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
55
# the ESRF by the Software group.
@@ -30,6 +30,12 @@
3030
import unittest
3131
import PyMca5.PyMcaGui.PyMcaQt as qt
3232
from PyMca5.PyMcaGui.misc.testutils import TestCaseQt
33+
try:
34+
import silx.gui
35+
SILX = True
36+
except Exception:
37+
# do not block tests because of any unforeseen silx exception
38+
SILX = False
3339

3440
_logger = logging.getLogger(__name__)
3541

@@ -231,6 +237,21 @@ def testShow(self):
231237
from PyMca5.PyMcaGui.plotting import PyMcaPrintPreview
232238
PyMcaPrintPreview.resetSingletonPrintPreview()
233239

240+
class TestHdf5NodeView(TestCaseQt):
241+
def setUp(self):
242+
super(TestHdf5NodeView, self).setUp()
243+
244+
@unittest.skipUnless(SILX, "silx not installed")
245+
def testShow(self):
246+
from PyMca5.PyMcaGui.io.hdf5.Hdf5NodeView import Plot2DViewWithPlugins
247+
dummy = qt.QWidget()
248+
widget = Plot2DViewWithPlugins(dummy)
249+
widget.createWidget(dummy)
250+
dummy.show()
251+
self.qapp.processEvents()
252+
from PyMca5.PyMcaGui.plotting import PyMcaPrintPreview
253+
PyMcaPrintPreview.resetSingletonPrintPreview()
254+
234255
class TestPyMcaMain(TestCaseQt):
235256
def setUp(self):
236257
super(TestPyMcaMain, self).setUp()
@@ -283,7 +304,8 @@ def runTest(self):
283304
TestXMCDWindow,
284305
TestPCAParametersDialog,
285306
TestPyMcaMain,
286-
):
307+
TestHdf5NodeView,
308+
):
287309
test_suite.addTest(
288310
unittest.defaultTestLoader.loadTestsFromTestCase(TestCaseCls))
289311
return test_suite

0 commit comments

Comments
 (0)