Do not allow to open more than 1 ammo pickers

This commit is contained in:
DarkPhoenix
2019-11-13 18:45:43 +03:00
parent 7ba5585b83
commit b05bd04801
2 changed files with 7 additions and 4 deletions

View File

@@ -53,14 +53,18 @@ class AuxiliaryFrame(wx.Frame):
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
@classmethod
def openOne(cls, parent, *args, **kwargs):
def openOne(cls, parent, *args, forceReopen=False, **kwargs):
"""If window is open and alive - raise it, open otherwise"""
if not cls._instance:
if not cls._instance or forceReopen:
if cls._instance:
cls._instance.Close()
frame = cls(parent, *args, **kwargs)
cls._instance = frame
frame.Show()
else:
cls._instance.Raise()
return cls._instance
def OnSuppressedAction(self, event):
return

View File

@@ -26,8 +26,7 @@ class GraphFitAmmoPicker(ContextMenuSingle):
return 'Plot with Different Ammo...'
def activate(self, callingWindow, fullContext, mainItem, i):
window = AmmoPickerFrame(callingWindow, mainItem.item)
window.Show()
AmmoPickerFrame.openOne(callingWindow, mainItem.item, forceReopen=True)
GraphFitAmmoPicker.register()