From ad90f2fccee30434efdeccd3b9654f91a239d556 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Fri, 25 Apr 2025 11:27:55 +0100 Subject: [PATCH 1/2] fix error on sample log plot resize --- .../widgets/samplelogs/test/test_samplelogs_view.py | 8 ++++++++ qt/python/mantidqt/mantidqt/widgets/samplelogs/view.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/qt/python/mantidqt/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py b/qt/python/mantidqt/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py index 2ca1ea4969b7..90de35a57958 100644 --- a/qt/python/mantidqt/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py +++ b/qt/python/mantidqt/mantidqt/widgets/samplelogs/test/test_samplelogs_view.py @@ -48,3 +48,11 @@ def test_workspace_updates(self): assert pres.view.isVisible() DeleteWorkspace("new_name") assert not pres.view.isVisible() + + def test_minimum_canvas_size(self): + ws = CreateSampleWorkspace() + pres = SampleLogs(ws) + pres.view.show_plot_and_stats(True) + pres.view.canvas.resize(-1, -1) + self.assertEqual(0, pres.view.canvas.width()) + self.assertEqual(0, pres.view.canvas.height()) diff --git a/qt/python/mantidqt/mantidqt/widgets/samplelogs/view.py b/qt/python/mantidqt/mantidqt/widgets/samplelogs/view.py index dffdb6a8814f..615ab4ed884f 100644 --- a/qt/python/mantidqt/mantidqt/widgets/samplelogs/view.py +++ b/qt/python/mantidqt/mantidqt/widgets/samplelogs/view.py @@ -24,7 +24,7 @@ QFrame, QSpacerItem, ) -from qtpy.QtCore import QItemSelectionModel, Qt, Signal +from qtpy.QtCore import QItemSelectionModel, Qt, Signal, QSize from mantidqt.widgets.observers.observing_view import ObservingView from mantidqt.MPLwidgets import FigureCanvas from mantid.api import Workspace @@ -123,6 +123,7 @@ def __init__(self, presenter, parent=None, window_flags=Qt.Window, name="", isMD self.fig = Figure() self.canvas = FigureCanvas(self.fig) self.canvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) + self.canvas.setMinimumSize(QSize(0, 0)) self.canvas.mpl_connect("button_press_event", self.presenter.plot_clicked) self.ax = self.fig.add_subplot(111, projection="mantid") layout_right.addWidget(self.canvas) @@ -169,7 +170,7 @@ def set_model(self, model): self.table.selectionModel().selectionChanged.connect(self.presenter.update) def show_plot_and_stats(self, show_plot_and_stats): - """sets wether the plot and stats section should be visible""" + """sets whether the plot and stats section should be visible""" if self.frame_right.isVisible() != show_plot_and_stats: # the desired state is nor the current state self.setUpdatesEnabled(False) From 5b1cbf21cd565dda62b37b368cc3b5b746ac1335 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:32:34 +0100 Subject: [PATCH 2/2] add release note --- docs/source/release/v6.13.0/Workbench/Bugfixes/39247.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/source/release/v6.13.0/Workbench/Bugfixes/39247.rst diff --git a/docs/source/release/v6.13.0/Workbench/Bugfixes/39247.rst b/docs/source/release/v6.13.0/Workbench/Bugfixes/39247.rst new file mode 100644 index 000000000000..2a7316ab02a0 --- /dev/null +++ b/docs/source/release/v6.13.0/Workbench/Bugfixes/39247.rst @@ -0,0 +1 @@ +- Minimizing the sample log plot on the ``SampleLogs`` widget so that it is not visible no longer throws an error.