From 1e35eaf62aaa9d0e4cad552ede6f1b7d789a2ab8 Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Mon, 12 Aug 2019 01:11:44 +0300 Subject: [PATCH] Rework how single windows are opened --- graphs/gui/frame.py | 5 +++++ gui/auxFrame.py | 1 + gui/builtinViews/entityEditor.py | 3 ++- gui/mainFrame.py | 25 ++++++------------------- gui/mainMenuBar.py | 2 +- gui/targetProfileEditor.py | 10 ++++++++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/graphs/gui/frame.py b/graphs/gui/frame.py index fe9ba4ea3..cc71be30f 100644 --- a/graphs/gui/frame.py +++ b/graphs/gui/frame.py @@ -140,6 +140,11 @@ class GraphFrame(AuxiliaryFrame): self.UpdateWindowSize() self.draw() + @classmethod + def openOne(cls, parent): + if graphFrame_enabled: + super().openOne(parent) + def UpdateWindowSize(self): curW, curH = self.GetSize() bestW, bestH = self.GetBestSize() diff --git a/gui/auxFrame.py b/gui/auxFrame.py index 4ca32a5ac..c17263021 100644 --- a/gui/auxFrame.py +++ b/gui/auxFrame.py @@ -45,6 +45,7 @@ class AuxiliaryFrame(wx.Frame): @classmethod def openOne(cls, parent): + """If window is open and alive - raise it, open otherwise""" if not cls._instance: frame = cls(parent) cls._instance = frame diff --git a/gui/builtinViews/entityEditor.py b/gui/builtinViews/entityEditor.py index c941657a5..e6224156e 100644 --- a/gui/builtinViews/entityEditor.py +++ b/gui/builtinViews/entityEditor.py @@ -173,8 +173,9 @@ class EntityEditor(wx.Panel): try: idx = self.choices.index(entity) except IndexError: - return + return False self.entityChoices.SetSelection(idx) + return True def checkEntitiesExist(self): if len(self.choices) == 0: diff --git a/gui/mainFrame.py b/gui/mainFrame.py index 4a609644d..8c26772cf 100644 --- a/gui/mainFrame.py +++ b/gui/mainFrame.py @@ -39,7 +39,7 @@ import gui.globalEvents as GE from eos.config import gamedata_date, gamedata_version # import this to access override setting from eos.modifiedAttributeDict import ModifiedAttributeDict -from graphs.gui import GraphFrame, frame as graphFrame +from graphs.gui import GraphFrame from gui.additionsPane import AdditionsPane from gui.bitmap_loader import BitmapLoader from gui.builtinMarketBrowser.events import ItemSelected @@ -211,9 +211,7 @@ class MainFrame(wx.Frame): self.SetMenuBar(MainMenuBar(self)) self.registerMenu() - # Internal vars to keep track of other windows (graphing/stats) - self.graphFrame = None - self.tgtProfileEditor = None + # Internal vars to keep track of other windows self.statsWnds = [] self.activeStatsWnd = None @@ -386,6 +384,9 @@ class MainFrame(wx.Frame): # info.WebSite = (forumUrl, "pyfa thread at EVE Online forum") wx.adv.AboutBox(info) + def OnShowGraphFrame(self, event): + GraphFrame.openOne(self) + def OnShowDevTools(self, event): DevTools.openOne(parent=self) @@ -399,13 +400,7 @@ class MainFrame(wx.Frame): self.ShowTargetProfileEditor() def ShowTargetProfileEditor(self, selected=None): - if not self.tgtProfileEditor: - self.tgtProfileEditor = TargetProfileEditor(self, selected=selected) - self.tgtProfileEditor.Show() - else: - if selected: - self.tgtProfileEditor.selectTargetProfile(selected) - self.tgtProfileEditor.Raise() + TargetProfileEditor.openOne(parent=self, selected=selected) def OnShowDamagePatternEditor(self, event): with DmgPatternEditorDlg(self) as dlg: @@ -959,14 +954,6 @@ class MainFrame(wx.Frame): def closeWaitDialog(self): del self.waitDialog - def OnShowGraphFrame(self, event): - if not self.graphFrame: - self.graphFrame = GraphFrame(self) - if graphFrame.graphFrame_enabled: - self.graphFrame.Show() - elif graphFrame.graphFrame_enabled: - self.graphFrame.Raise() - def openWXInspectTool(self, event): if not InspectionTool().initialized: InspectionTool().Init() diff --git a/gui/mainMenuBar.py b/gui/mainMenuBar.py index 9aa557075..0b42df0e6 100644 --- a/gui/mainMenuBar.py +++ b/gui/mainMenuBar.py @@ -23,7 +23,7 @@ import wx import config from service.character import Character from service.fit import Fit -from graphs.gui import GraphFrame, frame as graphFrame +from graphs.gui import frame as graphFrame import gui.globalEvents as GE from gui.bitmap_loader import BitmapLoader diff --git a/gui/targetProfileEditor.py b/gui/targetProfileEditor.py index 861169640..c2c5a3502 100644 --- a/gui/targetProfileEditor.py +++ b/gui/targetProfileEditor.py @@ -81,8 +81,8 @@ class TargetProfileNameValidator(BaseValidator): class TargetProfileEntityEditor(EntityEditor): - def __init__(self, parent, selected=None): - EntityEditor.__init__(self, parent=parent, entityName="Target Profile", selected=selected) + def __init__(self, parent): + EntityEditor.__init__(self, parent=parent, entityName="Target Profile") self.SetEditorValidator(TargetProfileNameValidator) self.mainFrame = gui.mainFrame.MainFrame.getInstance() @@ -251,6 +251,12 @@ class TargetProfileEditor(AuxiliaryFrame): self.patternChanged() + @classmethod + def openOne(cls, parent, selected=None): + super().openOne(parent) + if selected is not None: + cls._instance.selectTargetProfile(selected) + def OnFieldChanged(self, event=None): if event is not None: event.Skip()