title: wxpython Update panel new items
body: <p>Dear wxPython experts,</p>
  
  <p>I am a newbie in wxPython...</p>
  
  <p>I try to change a panel content according to wx.ListCtrl entries. It does not work perfectly : at the change, the panel content is overlapped by the previous content, and I would like to clear the panel before inserting the new content.</p>
  
  <p>Who could help me to understand my mistake ?</p>
  
  <p>Thanks a lot,</p>
  
  <p>Rémy</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#!/usr/bin/python
  # -*- coding: utf-8 -*-
  
  import wx
  
  class MainProcesses(wx.Panel):
      def __init__(self, parent):
          wx.Panel.__init__(self, parent, size=(500, 300) )
          self.parent = parent
          mainSZ = wx.BoxSizer(wx.VERTICAL)
          self.SetSizer(mainSZ)
          self.Layout()
          mainSZ.Clear(True)
  
          A_h = wx.StaticBox(self, -1, "Heading:")
          A_t = wx.TextCtrl(self, -1, "")
          A_sb = wx.StaticBox(self, -1, "Simulate")
          A_cb1 = wx.CheckBox(self, -1, "Water" )
          A_cb11 = wx.CheckBox(self, -1, "Vapor")
          A_cb12 = wx.CheckBox(self, -1, "Snow")
  
          A_cb2 = wx.CheckBox(self, -1, "Transport")
          A_rb21 = wx.RadioButton(self, -1, "Standard")
          A_rb22 = wx.RadioButton(self, -1, "Major")
          A_rb23 = wx.RadioButton(self, -1, "Evaluated")
  
          A_cb3 = wx.CheckBox(self, -1, "Heat transport")
          A_cb4 = wx.CheckBox(self, -1, "water uptake")
          A_cb5 = wx.CheckBox(self, -1, "Growth")
          A_cb6 = wx.CheckBox(self, -1, "CO2 transport")            
  
  
          bs_t = wx.StaticBoxSizer(A_h, wx.VERTICAL)
          bs_t.Add(A_t, 0, wx.ALL|wx.EXPAND)
          sbSZ = wx.StaticBoxSizer(A_sb, wx.VERTICAL|wx.ALIGN_LEFT)
          sbSZ.Add(A_cb1, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
          sbSZ.Add(A_cb11, 0, wx.LEFT, 20)
          sbSZ.Add(A_cb12, 0, wx.LEFT, 20)
          sbSZ.Add(A_cb2, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
          sbSZ.Add(A_rb21, 0, wx.LEFT, 20)
          sbSZ.Add(A_rb22, 0, wx.LEFT, 20)
          sbSZ.Add(A_rb23, 0, wx.LEFT, 20)
          sbSZ.Add(A_cb3, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
          sbSZ.Add(A_cb4, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
          sbSZ.Add(A_cb5, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
          sbSZ.Add(A_cb6, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
  
          mainSZ.Add(bs_t, wx.CENTER|wx.EXPAND, 3)
          mainSZ.Add(sbSZ, 0, wx.LEFT|wx.RIGHT|wx.TOP, 3)
  
          self.Layout()
  
  
  class GeometryInfo(wx.Panel):
      def __init__(self, parent):
          wx.Panel.__init__(self, parent, size=(500, 300) )
          self.parent = parent
          #print self.parent.GetSize()
          mainSZ = wx.BoxSizer(wx.VERTICAL)
          self.SetSizer(mainSZ)
          self.Layout()
          mainSZ.Clear(True)
  
          B_sb1 = wx.StaticBox(self, -1, "Length units", size=(100,-1))
          B_rb21 = wx.RadioButton(self, 0, "mm")
          B_rb22 = wx.RadioButton(self, 0, "cm")
          B_rb23 = wx.RadioButton(self, 0, "m")
  
          B_sb2 = wx.StaticBox(self, -1, "")
          B_NbSoilMat = wx.TextCtrl(self, -1, "1")
          B_NbLayers = wx.TextCtrl(self, -1, "1")
          B_h1 = wx.StaticText(self, -1, "Nomber of materials")
          B_h2 = wx.StaticText(self, -1, "Number of layers ")
  
          sbSZ1 = wx.StaticBoxSizer(B_sb1, wx.VERTICAL)
          sbSZ1.Add(B_rb21, 0, wx.ALL|wx.EXPAND, 5)
          sbSZ1.Add(B_rb22, 0, wx.ALL|wx.EXPAND, 5)
          sbSZ1.Add(B_rb23, 0, wx.ALL|wx.EXPAND, 5)
  
          sbSZ2 = wx.StaticBoxSizer(B_sb2, wx.VERTICAL|wx.ALIGN_LEFT)
          sbSZ21 = wx.BoxSizer( wx.HORIZONTAL )
          sbSZ21.Add(B_NbSoilMat, 0, wx.ALIGN_LEFT, 5)
          sbSZ21.Add(B_h1, 0, wx.ALL, 5)     
  
          sbSZ22 = wx.BoxSizer( wx.HORIZONTAL )
          sbSZ22.Add(B_NbLayers, 0, wx.ALIGN_LEFT, 5)
          sbSZ22.Add(B_h2, 0, wx.ALL, 5)
  
          sbSZ2.Add(sbSZ21, 0, wx.ALL, 5)
          sbSZ2.Add(sbSZ22, 0, wx.ALL, 5)
  
          mainSZ.Add(sbSZ1, 0, wx.ALL, 15)
          mainSZ.Add(sbSZ2, 0, wx.ALL, 15)
  
          self.Layout()
  
  
  # #####################################################################################################################        
  Configs = ['Main processes', 'Geometry']
  
  class ListCtrlLeft(wx.ListCtrl):
      def __init__(self, parent, id):
          wx.ListCtrl.__init__(self, parent, id, style=wx.LC_REPORT | wx.LC_HRULES | wx.LC_NO_HEADER | wx.LC_SINGLE_SEL)
          image = 'images/java.png'
  
          self.parent = parent
  
          self.Bind(wx.EVT_SIZE, self.OnSize)
          self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnSelect)
  
          self.il = wx.ImageList(32,32)
  
          self.il.Add(wx.Bitmap(image))
  
          self.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
          self.InsertColumn(0, '')
          L = len (Configs)
          for i in range ( L ):
              self.InsertStringItem(0, Configs[L-i-1])
              self.SetItemImage(0, 0)
  
      def OnSize(self, event):
          size = self.parent.GetSize()
          self.SetColumnWidth(0, size.x-5)
          event.Skip()
  
      def OnSelect(self, event):
          window = self.parent.GetGrandParent().FindWindowByName('PanelControlOnRight')
          index = event.GetIndex()
          window.LoadData(index)
  
      def OnFocus(self, event):
          self.SetItemBackgroundColour(0, 'red')
  
  class PanelMainProcess(wx.Panel):
      def __init__(self, parent): 
          wx.Panel.__init__(self, parent)
  
          self.parent = parent
          self.Bind(wx.EVT_SIZE, self.OnSize)
  
      def OnSize(self, event):
          event.Skip()   
  
      def LoadData(self, index):        
          mainSZ = wx.BoxSizer(wx.VERTICAL)
  
          mainSZ.Layout()        
  
          if index == 0:            
              self.p = MainProcesses(self.parent)
              mainSZ.Add( self.p )
  
          elif index==1:
              self.geoinfo = GeometryInfo(self.parent)
              mainSZ.Add( self.geoinfo )      
          else:
              print "Index not found"
  
          self.SetSizer(mainSZ)
          mainSZ.Fit(self)
          mainSZ.Layout()
  
  class MyFrame(wx.Dialog):
      def __init__(self, parent, id, title):
          wx.Dialog.__init__(self, parent, id, title)
          self.mainbox = wx.BoxSizer(wx.VERTICAL)
          hbox = wx.BoxSizer(wx.HORIZONTAL)
          splitter = wx.SplitterWindow(self, -1, style=wx.SP_LIVE_UPDATE|wx.SP_NOBORDER)
          vbox1 = wx.BoxSizer(wx.VERTICAL)
          panel1 = wx.Panel(splitter, -1 )
  
          panel12 = wx.Panel(panel1, -1, style=wx.BORDER_SUNKEN)
          vbox = wx.BoxSizer(wx.VERTICAL)
          list1 = ListCtrlLeft(panel12, -1)
  
          vbox.Add(list1, 2, wx.EXPAND)
          panel12.SetSizer(vbox)
          #panel12.SetBackgroundColour('WHITE')
  
          vbox1.Add(panel12, 1, wx.EXPAND)
  
          panel1.SetSizer(vbox1)
  
          vbox2 = wx.BoxSizer(wx.VERTICAL)
          panel2 = wx.Panel(splitter, -1)
  
          panel22 = wx.Panel(panel2, -1, style=wx.BORDER_SUNKEN)
          vbox3 = wx.BoxSizer(wx.VERTICAL)
  
          self.Main = PanelMainProcess(panel22)
          self.Main.SetName('PanelControlOnRight')
  
          vbox3.Add(self.Main, 1, wx.EXPAND)
          panel22.SetSizer(vbox3)
  
          panel22.SetBackgroundColour('WHITE')
          vbox2.Add(panel22, 1, wx.EXPAND)
  
          panel2.SetSizer(vbox2)
          panel2.SetAutoLayout(True)
  
          vbox2.Fit(self)
  
          splitter.SplitVertically(panel1, panel2)
  
          hbox.Add(splitter, 1, wx.EXPAND | wx.TOP | wx.BOTTOM, 5)
  
          hhbox = wx.BoxSizer(wx.HORIZONTAL)
          bOk = wx.Button(self, wx.ID_OK, "Ok")
  
          hhbox.AddStretchSpacer(100)
          hhbox.Add(bOk, 0, wx.RIGHT,5)
  
          self.mainbox.Add(hbox, 1, wx.EXPAND, 10)
          self.mainbox.Add(hhbox, 0, wx.EXPAND|wx.ALL|wx.ALIGN_RIGHT, 10)
          self.SetSizer(self.mainbox)
  
          self.SetSize( (1200,500) )
  
          bOk.Bind(wx.EVT_BUTTON, self.OnOk)
  
      def OnOk(self, event):
          self.Destroy()
  
  class MyApp(wx.App):
      def OnInit(self):
          f = MyFrame(None, -1, "Title")
          f.Show(True)
          self.SetTopWindow(f)
          return True
  
  app = MyApp()
  app.MainLoop()        
  </code></pre>