I want to delete a panel ( mainPanel )and replace a panel ( secPanel )in its place. The code I have tried:
import wx
class secPanel ( wx.Panel ):
def __init__ ( self, parent ):
wx.Panel.__init__ ( self, parent = parent )
wx.TextCtrl ( self, pos = ( 100, 100 ) )
class mainPanel ( wx.Panel ):
def __init__ ( self, parent ):
wx.Panel.__init__ ( self, parent = parent )
self.parent = parent
b = wx.Button ( self, label = "Test", pos = ( 100, 100 ) )
self.Bind ( wx.EVT_BUTTON, self.onPress, b )
def onPress ( self, event ):
parent = self.parent
self.Destroy()
secPanel ( parent )
class Window ( wx.Frame ):
def __init__ ( self ):
wx.Frame.__init__ ( self, parent = None, title = "" )
mainPanel ( self )
self.Show()
if __name__ == "__main__":
app = wx.App()
window = Window()
app.MainLoop()
The mainPanel gets deleted but the secPanel only shows when the window is resized ( even just a pixel works ). Until I resize it shows a grey screen ( the one which would show without any panel ). This is quite annoying.