From 4e3d8b9da6e8fbe7634a302fbe7136b56648fb1e Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 27 Jan 2023 18:34:17 +0100 Subject: [PATCH] introduced MDISubPlotBase --- grum/mdi/mdisubplot.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/grum/mdi/mdisubplot.py b/grum/mdi/mdisubplot.py index 1c77d0f..57ca35d 100644 --- a/grum/mdi/mdisubplot.py +++ b/grum/mdi/mdisubplot.py @@ -3,30 +3,36 @@ from .mdisubwin import MDISubWindow from ..theme import pg_plot_style, pg_plot_style_cycler, pg_legend_style -class MDISubPlot(MDISubWindow): +class MDISubPlotBase(MDISubWindow): + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.pw = pw = pg.PlotWidget() + self.setWidget(pw) + + + +class MDISubPlot(MDISubPlotBase): def __init__(self, name, desc, *args, **kwargs): super().__init__(name, *args, **kwargs) - pw = pg.PlotWidget() - self.setWidget(pw) style = pg_plot_style() - plot = desc.make_plot(pw, style) + plot = desc.make_plot(self.pw, style) self.plots = {name: plot} -class MDISubMultiPlot(MDISubWindow): +class MDISubMultiPlot(MDISubPlotBase): def __init__(self, name, descs, *args, **kwargs): super().__init__(name, *args, **kwargs) - pw = pg.PlotWidget() - self.setWidget(pw) ls = pg_legend_style() psc = pg_plot_style_cycler() + pw = self.pw pw.addLegend(**ls) self.plots = {name: desc.make_plot(pw, style) for (name, desc), style in zip(descs.items(), psc)}