introduced MDISubPlotBase

This commit is contained in:
2023-01-27 18:34:17 +01:00
parent 764760df1f
commit 4e3d8b9da6

View File

@ -3,30 +3,36 @@ from .mdisubwin import MDISubWindow
from ..theme import pg_plot_style, pg_plot_style_cycler, pg_legend_style 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): def __init__(self, name, desc, *args, **kwargs):
super().__init__(name, *args, **kwargs) super().__init__(name, *args, **kwargs)
pw = pg.PlotWidget()
self.setWidget(pw)
style = pg_plot_style() style = pg_plot_style()
plot = desc.make_plot(pw, style) plot = desc.make_plot(self.pw, style)
self.plots = {name: plot} self.plots = {name: plot}
class MDISubMultiPlot(MDISubWindow): class MDISubMultiPlot(MDISubPlotBase):
def __init__(self, name, descs, *args, **kwargs): def __init__(self, name, descs, *args, **kwargs):
super().__init__(name, *args, **kwargs) super().__init__(name, *args, **kwargs)
pw = pg.PlotWidget()
self.setWidget(pw)
ls = pg_legend_style() ls = pg_legend_style()
psc = pg_plot_style_cycler() psc = pg_plot_style_cycler()
pw = self.pw
pw.addLegend(**ls) pw.addLegend(**ls)
self.plots = {name: desc.make_plot(pw, style) for (name, desc), style in zip(descs.items(), psc)} self.plots = {name: desc.make_plot(pw, style) for (name, desc), style in zip(descs.items(), psc)}