From fc7613451ed3f1509a0115c96a20ebcf0be7df5f Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Sat, 29 Jun 2019 11:21:54 +0300 Subject: [PATCH] Copy functionality from fit list to target list --- gui/graphFrame/lists.py | 31 ++++++++++++++----------------- gui/graphFrame/panel.py | 3 ++- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/gui/graphFrame/lists.py b/gui/graphFrame/lists.py index 02ccb6546..a9b3ba340 100644 --- a/gui/graphFrame/lists.py +++ b/gui/graphFrame/lists.py @@ -26,7 +26,7 @@ import gui.globalEvents as GE from service.fit import Fit -class FitList(gui.display.Display): +class BaseList(gui.display.Display): DEFAULT_COLS = ( 'Base Icon', @@ -40,11 +40,6 @@ class FitList(gui.display.Display): fitToolTip = wx.ToolTip('Drag a fit into this list to graph it') self.SetToolTip(fitToolTip) - fit = Fit.getInstance().getFit(self.graphFrame.mainFrame.getActiveFit()) - if fit is not None: - self.fits.append(fit) - self.update(self.fits) - self.contextMenu = wx.Menu() removeItem = wx.MenuItem(self.contextMenu, 1, 'Remove Fit') self.contextMenu.Append(removeItem) @@ -55,7 +50,6 @@ class FitList(gui.display.Display): self.Bind(wx.EVT_CHAR_HOOK, self.kbEvent) self.Bind(wx.EVT_CONTEXT_MENU, self.OnContextMenu) - def kbEvent(self, event): keycode = event.GetKeyCode() mstate = wx.GetMouseState() @@ -125,15 +119,18 @@ class FitList(gui.display.Display): self.graphFrame.draw() -class TargetList(gui.display.Display): - - DEFAULT_COLS = ( - 'Base Icon', - 'Base Name') +class FitList(BaseList): def __init__(self, graphFrame, parent): - super().__init__(parent) - self.graphFrame = graphFrame - self.targetFits = [] - fitToolTip = wx.ToolTip('Drag a fit into this list to graph it') - self.SetToolTip(fitToolTip) + super().__init__(graphFrame, parent) + fit = Fit.getInstance().getFit(self.graphFrame.mainFrame.getActiveFit()) + if fit is not None: + self.fits.append(fit) + self.update(self.fits) + + +class TargetList(BaseList): + + def __init__(self, graphFrame, parent): + super().__init__(graphFrame, parent) + self.update(self.fits) diff --git a/gui/graphFrame/panel.py b/gui/graphFrame/panel.py index b08e19ce4..8ae9a127f 100644 --- a/gui/graphFrame/panel.py +++ b/gui/graphFrame/panel.py @@ -298,10 +298,11 @@ class GraphControlPanel(wx.Panel): @property def targets(self): - return self.targetList.targetFits + return self.targetList.fits def unbindExternalEvents(self): self.fitList.unbindExternalEvents() + self.targetList.unbindExternalEvents() def formatLabel(self, axisDef): if axisDef.unit is None: