Display update after detaching the last panel from a flex grid sizer

What do I need to do to the sample code below to cause the display to
update after deleting (vial Panel | Detach leading panel) the last
panel?

Bob

···

`import wx

class MainFrame(wx.Frame):

def init(self, parent, id, title):

   wx.Frame.__init__(self, parent, -1,

title)

   self.menu = wx.Menu()

   item_DETACH = self.menu.Append(101,

“&Detach leading panel”)

   menuBar = wx.MenuBar()

   menuBar.Append(self.menu,

“&Panel”,)

   self.SetMenuBar(menuBar)

   self.Bind(wx.EVT_MENU,

self.OnDetach, item_DETACH)

   pnl = wx.Panel(self,-1)

   self.mainsizer =

wx.BoxSizer(wx.VERTICAL)

   self.fgs = wx.FlexGridSizer(1, 2, 1,
  1. rows, cols, vgap, hgap

    self.fgs.AddGrowableRow(0)

    self.fgs.AddGrowableCol(0)

    self.fgs.AddGrowableCol(1)

    pnl00 = self.fgs.Add(ChildPanel(pnl,
    -1,‘win00’), flag=wx.EXPAND)

    pnl01 = self.fgs.Add(ChildPanel(pnl,
    -1,‘win01’), flag=wx.EXPAND)

    pnl.SetSizer(self.fgs)

    self.mainsizer.Add(pnl, 1,
    wx.EXPAND)

self.SetSizer(self.mainsizer)

   self.fgs.Layout()

   self.mainsizer.Layout()

def OnDetach(self,evt):

    self.fgs.Detach(0)

    self.fgs.Layout()

self.mainsizer.Layout()

class ChildPanel(wx.Panel):

def init(self, parent, id, title):

   wx.Panel.__init__(self, parent, -1,

style=wx.RAISED_BORDER)

   pnl = wx.Panel(self,-1)

pnl.SetBackgroundColour(wx.BLUE)

   st_ttl = wx.StaticText(self, -1,

title, size=(20,20)

     ,

style=wx.ALIGN_CENTER|wx.RAISED_BORDER|wx.ST_NO_AUTORESIZE)

st_ttl.SetBackgroundColour(wx.WHITE)

   bs = wx.BoxSizer(wx.VERTICAL)

   bs.Add(st_ttl, 0,

wx.EXPAND)

   bs.Add(pnl, 1, wx.EXPAND)

   self.SetSizer(bs)

   bs.Layout()

if name == ‘main’:

app = wx.App(redirect=False)

frame = MainFrame(None, -1, “Titled-panels-in-frame
detach test”)

frame.Show()

app.MainLoop()

`

Bob Klahn wrote:

What do I need to do to the sample code below to cause the display to update after deleting (vial Panel | Detach leading panel) the last panel?

Detach doesn't destroy the window, so it is still where it was when the sizer stopped managing it. If you want it to be totally gone you need to Destroy() yourself.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hmmm, then why do all but the last panel disappear from the display when I detach them?? I haven't destroyed any of them.

Bob

···

At 09:58 PM 10/28/2006, Robin wrote:

Bob Klahn wrote:

What do I need to do to the sample code below to cause the display to update after deleting (vial Panel | Detach leading panel) the last panel?

Detach doesn't destroy the window, so it is still where it was when the sizer stopped managing it. If you want it to be totally gone you need to Destroy() yourself.

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.0.408 / Virus Database: 268.13.17/505 - Release Date: 10/27/2006