python - wxPython: Ensure only one instance of a panel is open -


i'm writing multi-window, multi-frame application. every new window/frame opened, there should 1 , 1 instance of window. want user able switch between these windows, showmodal() not work. i've tried using singleinstancechecker, can't work it's more apps frames. how should accomplish this?

i did bit of google-fu , found old thread:

using template, put little script , appears work on linux box:

import wx  ######################################################################## class mypanel(wx.panel):     """"""      #----------------------------------------------------------------------     def __init__(self, parent):         """constructor"""         wx.panel.__init__(self, parent)   ######################################################################## class singleinstanceframe(wx.frame):     """"""      instance = none     init = 0      #----------------------------------------------------------------------     def __new__(self, *args, **kwargs):         """"""         if self.instance none:             self.instance = wx.frame.__new__(self)         elif isinstance(self.instance, wx._core._wxpydeadobject):             self.instance = wx.frame.__new__(self)         return self.instance      #----------------------------------------------------------------------     def __init__(self):         """constructor"""         print id(self)         if self.init:             return         self.init = 1          wx.frame.__init__(self, none, title="single instance frame")         panel = mypanel(self)         self.show()    ######################################################################## class mainframe(wx.frame):     """"""      #----------------------------------------------------------------------     def __init__(self):         """constructor"""         wx.frame.__init__(self, none, title="main frame")         panel = mypanel(self)         btn = wx.button(panel, label="open frame")         btn.bind(wx.evt_button, self.open_frame)         self.show()      #----------------------------------------------------------------------     def open_frame(self, event):         frame = singleinstanceframe()  if __name__ == '__main__':     app = wx.app(false)     frame = mainframe()     app.mainloop() 

Comments