This does what you want I think. I haven't tested multiple panels in the foldpanelbar, you might need to limit the size of the foldpanelbar explicitly to prevent it from getting too wide.
import wx
import wx.lib.agw.foldpanelbar as fpb
class frame(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.text_ctrl_1=wx.TextCtrl(self, -1, size=(400, 100),
style=wx.TE_MULTILINE)
self.fpb = fpb.FoldPanelBar(self, -1,
style=fpb.FPB_HORIZONTAL|fpb.FPB_DEFAULT_STYLE)
self.fold_panel = self.fpb.AddFoldPanel("Thing")
self.thing = wx.TextCtrl(self.fold_panel, -1, size=(400, -1),
style=wx.TE_MULTILINE)
self.fpb.AddFoldPanelWindow(self.fold_panel, self.thing)
self.fpb.Bind(fpb.EVT_CAPTIONBAR, self.onCaptionBar)
self.sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
self.sizer_1.Add(self.text_ctrl_1, 1, wx.EXPAND)
self.sizer_1.Add(self.fpb, 0, wx.EXPAND)
self.SetSizer(self.sizer_1)
self.ResizeFPB()
def onCaptionBar(self, event):
event.Skip()
wx.CallAfter(self.ResizeFPB)
def ResizeFPB(self):
sizeNeeded = self.fpb.GetPanelsLength(0, 0)[2]
self.fpb.SetMinSize((sizeNeeded, self.fpb.GetSize()[1]))
self.Fit()
app = wx.App(0)
f = frame(None)
f.Show()
app.MainLoop()
Frank Niessink
2009-05-05 16:15:57