The above code will work fine if the 'childframe' variable is an
instantiated instance of the object and is a child of the 'mainframe'.
2) Another way is if the child frame is a unique subclass that will
only have on instance at a time,
def OnLaunchChild(self,evt):
for child in frame.GetChildren():
if isinstance(child, MyChildFrameClass):
child.Raise()
return
else:
new_child = MyChildFrameClass(frame)
new_child.Show()
3) And another way would be to make the child frame class a singleton
class so that it is only possible to instantiate a single instance of
it at a time.
4) Yet another way is to keep reference to the instance of the child
frame.
def OnLaunchChild(self,evt):
if isinstance(self.child, wx.Frame): # check for dead objects
self.child.Raise()
else:
self.child = MyChildFrameClass(self)
self.child.Show()
Cody
There's also the hasattr() function that I've recently learned about
thru this forum if you create the child frame with a specific name
self.new_child = MyChildFrameClass(frame)
I'd think you could simply test to see if you've created that yet:
if hasattr(self, "new_child")
... or something along those lines. Don't quote me on my syntax as
I'm a novice but I've been using 'hasattr' successfully in such
circumstances.