title: WxPython Panel Refresh
body: <p><strike>Unfortunately, because its giant and dependent on a lot of other things, I can't post proper code for y'all to test, so sorry in advance</strike></p>
  
  <p>So the general idea is that I have a panel which displays information from a log (a <code>dict</code> called <code>CRDict</code>).  This log holds the past revisions and I want the user to be able to select which revision they view.  So I move the entire setup (creating and filling sizers based on what is in <code>self.CRDict</code>) into a function called <code>Display()</code>.  This function sets up a drop down and binds it to a function <code>OnRevDrop()</code> which lets the user select which revision to show.  The function <code>OnRevDrop()</code> decides which then assigns <code>self.CRDict</code> to be the <code>dict</code> which holds the info for the selected revision. </p>
  
  <p>The problem is that it only works once.  The user opens the panel, the current revision displays, the user selects a different revision, the panel refreshes and shows the information from the selected revision, then the user selects another revision, and it breaks giving a <code>KeyError</code>.  The error is because calling the <code>GetValue()</code> function on the drop down <em>returns an empty string.</em> This is the source of my problem, though I do not know how to solve it.  </p>
  
  <p>Does anyone have any insight as to why this might be occurring?  </p>
  
  <p>Thanks in advance   </p>
  
  <hr>
  
  <h1>Alright, working code!</h1>
  
  <pre><code>import wx
  from wx.lib.scrolledpanel import ScrolledPanel 
  
  rev1 = {"A": "a", "B": "b", "C": "c"}
  rev2 = {"A": "d", "B": "e", "C": "f"}
  rev3 = {"A": "g", "B": "h", "C": "i"}
  
  RevHist = {"1":rev1, "2":rev2, "3":rev3}
  
  
  class TestGui(wx.Frame):
      def __init__(self):
          wx.Frame.__init__(self, None, -1, "Hey, a GUI!", size=(400,400)) 
          self.panel = ScrolledPanel(parent=self, id=-1) 
  
          self.revsList = sorted(RevHist.keys())
          self.CRDict = rev3 
  
          self.Display()
          self.revDrop.SetValue("3")
  
  
      def Display(self):
          crrev = wx.StaticText(self.panel, -1, "Revision:")
          self.revDrop = wx.ComboBox(self.panel, choices=self.revsList, style = wx.CB_READONLY)
          self.Bind(wx.EVT_COMBOBOX, self.OnRevDrop, self.revDrop)
  
          hboxRev = wx.BoxSizer(wx.HORIZONTAL)
          hboxRev.Add((20,20), 1)
          hboxRev.Add(crrev)
          hboxRev.Add((0,0), 1)
          hboxRev.Add(self.revDrop)
          hboxRev.Add((20,20), 1)
  
          sbox1 = wx.StaticBox(self.panel, wx.ID_ANY, u"Here's where the information goes")
          sbox1.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD))
          self.staticbox1 = wx.StaticBoxSizer(sbox1, wx.VERTICAL)
  
          infoA = wx.StaticText(self.panel, -1, "A: {}".format(self.CRDict["A"]))
          infoB = wx.StaticText(self.panel, -1, "B: {}".format(self.CRDict["B"]))
          infoC = wx.StaticText(self.panel, -1, "C: {}".format(self.CRDict["C"]))
  
          self.staticbox1.Add(infoA, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=10)
          self.staticbox1.Add(infoB, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=10)
          self.staticbox1.Add(infoC, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=10)
  
          self.vbox = wx.BoxSizer(wx.VERTICAL)
          self.vbox.Add(hboxRev, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=10)    
          self.vbox.Add(self.staticbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP|wx.BOTTOM, border=10) 
          self.panel.SetSizer(self.vbox)
          self.panel.Layout()
  
      def OnRevDrop(self, event):
          rev = self.revDrop.GetValue()
          print rev
          self.CRDict = RevHist[rev]
  
          self.Display()
  
  
  app = wx.PySimpleApp()
  gui = TestGui()
  gui.Show()
  app.MainLoop()
  </code></pre>