Rework how single frame of some auxiliary window is opened

This commit is contained in:
DarkPhoenix
2019-08-12 00:48:18 +03:00
parent 34a6fdc07e
commit 8a3dc2f3dc
3 changed files with 17 additions and 17 deletions

View File

@@ -24,6 +24,8 @@ import wx
class AuxiliaryFrame(wx.Frame):
_instance = None
def __init__(self, parent, id=None, title=None, pos=None, size=None, style=None, name=None):
baseStyle = wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT | wx.CAPTION | wx.CLOSE_BOX | wx.SYSTEM_MENU
kwargs = {
@@ -40,3 +42,12 @@ class AuxiliaryFrame(wx.Frame):
if name is not None:
kwargs['name'] = name
super().__init__(**kwargs)
@classmethod
def openOne(cls, parent):
if not cls._instance:
frame = cls(parent)
cls._instance = frame
frame.Show()
else:
cls._instance.Raise()

View File

@@ -1391,7 +1391,7 @@ class PFNotebookPagePreview(wx.Frame):
if self.transp < 0:
self.transp = 0
self.timer.Stop()
wx.Frame.Show(self, False)
super().Show(False)
self.Destroy()
return
self.SetTransparent(self.transp)
@@ -1407,7 +1407,7 @@ class PFNotebookPagePreview(wx.Frame):
def Show(self, showWnd=True):
if showWnd:
wx.Frame.Show(self, showWnd)
super().Show(showWnd)
self.RaiseParent()
self.direction = 1
self.timer.Start(10)

View File

@@ -137,7 +137,7 @@ class MainFrame(wx.Frame):
def __init__(self, title="pyfa"):
pyfalog.debug("Initialize MainFrame")
self.title = title
wx.Frame.__init__(self, None, wx.ID_ANY, self.title)
super().__init__(None, wx.ID_ANY, self.title)
self.supress_left_up = False
MainFrame.__instance = self
@@ -212,11 +212,8 @@ class MainFrame(wx.Frame):
self.registerMenu()
# Internal vars to keep track of other windows (graphing/stats)
self.charEditor = None
self.attrEditor = None
self.graphFrame = None
self.tgtProfileEditor = None
self.devTools = None
self.statsWnds = []
self.activeStatsWnd = None
@@ -390,13 +387,13 @@ class MainFrame(wx.Frame):
wx.adv.AboutBox(info)
def OnShowDevTools(self, event):
self.bringUpWindow('devTools', DevTools)
DevTools.openOne(parent=self)
def OnShowCharacterEditor(self, event):
self.bringUpWindow('charEditor', CharacterEditor)
CharacterEditor.openOne(parent=self)
def OnShowAttrEditor(self, event):
self.bringUpWindow('attrEditor', AttributeEditor)
AttributeEditor.openOne(parent=self)
def OnShowTargetProfileEditor(self, event):
self.ShowTargetProfileEditor()
@@ -980,11 +977,3 @@ class MainFrame(wx.Frame):
if not wnd:
wnd = self
InspectionTool().Show(wnd, True)
def bringUpWindow(self, attrName, windowClass):
if not getattr(self, attrName):
frame = windowClass(self)
setattr(self, attrName, frame)
frame.Show()
else:
getattr(self, attrName).Raise()