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,
-
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()