Hiding controls (again)

My apologies, it seems the attachment didn't make it
through, so I'll try to post it below...

---start code---
#!/usr/bin/env python

import wx

ID_BUTTON1 = wx.NewId()
ID_BUTTON2 = wx.NewId()
ID_BUTTON3 = wx.NewId()
ID_RADIOBUTTON1 = wx.NewId()
ID_RADIOBUTTON2 = wx.NewId()
ID_RADIOBUTTON3 = wx.NewId()
ID_TOGGLE = wx.NewId()

class MyFrame(wx.Frame):
  def __init__(self, parent=None, id=-1,
    title='My Frame',
    pos=(-1, -1),
    size=(-1, -1),
    style=wx.DEFAULT_FRAME_STYLE):
    wx.Frame.__init__(self, parent, id, title, pos,
size, style)

    self.SetBackgroundColour(wx.WHITE)

    self.frameSizer = wx.BoxSizer(wx.VERTICAL)
    self.framePanel = MyPanel(self)
    self.frameSizer.Add(self.framePanel, 0,
wx.ALIGN_CENTER|wx.ALL, 0)
    self.SetSizerAndFit(self.frameSizer)

class MyPanel(wx.Panel):
  def __init__(self, parent):
    wx.Panel.__init__(self, parent, -1,
      pos = (-1, -1),
      size = (-1, -1))

    # use parent background color
    color = parent.GetBackgroundColour()
    self.SetBackgroundColour(color)

    # create panel controls
    self.topSizer = wx.BoxSizer(wx.VERTICAL)
    
    self.btnSizer = wx.BoxSizer(wx.HORIZONTAL)
    
    self.button1 = wx.Button(self, ID_BUTTON1, 'Button
1')
    self.btnSizer.Add(self.button1, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.button2 = wx.Button(self, ID_BUTTON2, 'Button
2')
    self.btnSizer.Add(self.button2, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.button3 = wx.Button(self, ID_BUTTON3, 'Button
3')
    self.btnSizer.Add(self.button3, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.topSizer.Add(self.btnSizer, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    # On linux/GTK, the static box doesn't inherit the
background
    # color of the parent. On MSWin, it does.
    self.stcBoxSizer = wx.StaticBox(self, -1, 'Static
Box')
    self.stcSizer = wx.StaticBoxSizer(self.stcBoxSizer,
wx.VERTICAL)
    
    self.radioButton1 = wx.RadioButton(self,
ID_RADIOBUTTON1, 'Radio Button 1', style =
wx.RB_GROUP)
    self.radioButton1.SetValue(True)
    self.stcSizer.Add(self.radioButton1, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.radioButton2 = wx.RadioButton(self,
ID_RADIOBUTTON2, 'Radio Button 2')
    self.stcSizer.Add(self.radioButton2, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.radioButton3 = wx.RadioButton(self,
ID_RADIOBUTTON3, 'Radio Button 3')
    self.stcSizer.Add(self.radioButton3, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.toggleButton = wx.ToggleButton(self, ID_TOGGLE,
'Toggle')
    self.stcSizer.Add(self.toggleButton, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.topSizer.Add(self.stcSizer, 0,
wx.ALIGN_CENTER|wx.ALL, 5)

    self.SetSizer(self.topSizer)

    # Layout() and Fit() don't seem to want to calculate
the
    # panel layout until after the next four lines of
code

    self.topSizer.Layout()
    self.topSizer.Fit(self)
# self.topSizer.SetSizeHints(self)

    self.Bind(wx.EVT_TOGGLEBUTTON, self.OnButton, id =
ID_TOGGLE)

# un-comment the next three lines to reproduce the
problem
    val = not self.toggleButton.GetValue()
    self.toggleButton.SetValue(val)
    self.OnButton(wx.PyEvent())

  def OnButton(self, event):
    """Show/Hide the row of buttons and the static
box"""
    val = not self.toggleButton.GetValue()
    self.button1.Show(val)
    self.button2.Show(val)
    self.button3.Show(val)
    self.stcBoxSizer.Show(val)

class MyApp(wx.App):
  def OnInit(self):
    self.frame = None
    return True

def main():
  app = MyApp(0)
  app.frame = MyFrame()
  app.SetTopWindow(app.frame)
  app.frame.Show(True)
  app.MainLoop()

if __name__ == '__main__':
  main()
---end code---

···

__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs