Rework how single windows are opened

This commit is contained in:
DarkPhoenix
2019-08-12 01:11:44 +03:00
parent 8a3dc2f3dc
commit 1e35eaf62a
6 changed files with 23 additions and 23 deletions

View File

@@ -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()

View File

@@ -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

View File

@@ -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:

View File

@@ -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()

View File

@@ -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

View File

@@ -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()