From 6f17db566c7e5c8a0dd34e6c084f3a723928edf7 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Tue, 1 Dec 2020 22:15:37 +0100 Subject: [PATCH] refactor for easier multi-curve plotting --- slic/gui/daqpanels.py | 3 ++- slic/gui/plotwidgets.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/slic/gui/daqpanels.py b/slic/gui/daqpanels.py index a12a8669..96532b32 100644 --- a/slic/gui/daqpanels.py +++ b/slic/gui/daqpanels.py @@ -433,7 +433,8 @@ class TweakPanel(wx.Panel): xs = [datetime.strptime(x, date_fmt) for x in xs] ys = [float(y) for y in ys] - dlg = PlotDialog("Tweak History", "step", xs, ys, ".-") + dlg = PlotDialog("Tweak History") + dlg.plot.step(xs, ys, ".-") dlg.plot.figure.autofmt_xdate() dlg.ShowModal() dlg.Destroy() diff --git a/slic/gui/plotwidgets.py b/slic/gui/plotwidgets.py index 1e192511..c555c0ec 100644 --- a/slic/gui/plotwidgets.py +++ b/slic/gui/plotwidgets.py @@ -13,19 +13,16 @@ from .widgets import WX_DEFAULT_RESIZABLE_DIALOG_STYLE class PlotDialog(wx.Dialog): - def __init__(self, title, method, *args, **kwargs): + def __init__(self, title): wx.Dialog.__init__(self, None, title=title, style=WX_DEFAULT_RESIZABLE_DIALOG_STYLE) self.plot = plot = PlotPanel(self) - method = getattr(plot, method) - method(*args, **kwargs) - plot.draw() self.status_bar = status_bar = wx.StatusBar(self) status_bar.SetFieldsCount(3) # toolbar help, x, y self.Bind(wx.EVT_TOOL_ENTER, self.update_statusbar_help) - self.plot.canvas.mpl_connect("motion_notify_event", self.update_statusbar_coord) + plot.canvas.mpl_connect("motion_notify_event", self.update_statusbar_coord) vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(plot, proportion=1, flag=wx.ALL|wx.EXPAND, border=0) @@ -34,6 +31,10 @@ class PlotDialog(wx.Dialog): self.SetSizerAndFit(vbox) + def ShowModal(self): + self.plot.draw() + wx.Dialog.ShowModal(self) + def GetStatusBar(self): return self.status_bar