Ive managed to make a small example of what I would like to achieve. When I double click on the green panel, it dissapears which is what I want and when I double click on the red panel the green panel appears again which is also fine. What I am having trouble with is how do I move the green panel up to take the place of the red panel when the red panel is not shown and remove the green panel back to how it was when the red panel appears, without having to change the position of them in the grid sizer.
Can someone please help?
Below is the template code which I am trying to achieve this:
import wx
class myframe(wx.Frame):
def __init__(self):
"Constructor. No arguments"
wx.Frame.__init__(self, None, size=(2000,2000))
self.myPanel1 = wx.Panel( self, size=(300, 300) )
myPanel2 = wx.Panel( self, size=(300, 300) )
self.myPanel1.SetBackgroundColour("green")
myPanel2.SetBackgroundColour("red")
myGridSizer = wx.GridBagSizer()
myGridSizer.Add(self.myPanel1, pos=(0, 0), span=(1,1), flag=wx.EXPAND)
myGridSizer.Add(myPanel2, pos=(1, 0), span=(1,1), flag=wx.EXPAND)
self.SetSizer(myGridSizer)
self.myPanel1.Bind(wx.EVT_LEFT_DCLICK, self.hideMe)
myPanel2.Bind(wx.EVT_LEFT_DCLICK, self.showMe)
def hideMe(self, event):
print "hide!"
self.myPanel1.Hide()
def showMe(self, event):
print "show!"
self.myPanel1.Show()
if __name__ == "__main__":
print "Running Demo"
app = wx.App()
region = myframe()
region.Show()
app.MainLoop()