I’m still having trouble getting ScrolledPanel to fit nicely into a Frame. I’ve appended the sample app; this doesn’t exactly reproduce all of my problems, but for a start, the frame doesn’t expand to show the full panels, but if I try to call Fit(), I end up with a blank white box - no widgets, no decorations, nothing. (wxPython 2.8.10.1, Python 2.6.4, OS X 10.6) I can’t set the frame size manually, because I won’t actually know how large the inner panel will be in advance.
By the way: SetMinSize() can’t be used to reduce the minimum size after it’s already been set once, correct? (This is problematic, but I can work around it if I can figure out the other bugs.)
thanks,
Nat
import wx, wx.lib.scrolledpanel
text = “The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.”
class MyFrame (wx.Frame) :
def init (self, *args, **kwds) :
wx.Frame.init(self, *args, **kwds)
top_panel = wx.Panel(self)
top_sizer = wx.BoxSizer(wx.VERTICAL)
top_panel.SetSizer(top_sizer)
panel = wx.lib.scrolledpanel.ScrolledPanel(top_panel, -1, style=wx.SUNKEN_BORDER)
panel.SetBackgroundColour((200,255,255))
top_sizer.Add(panel, 1, wx.ALL|wx.EXPAND)
panel_sizer = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(panel_sizer)
for i in range(10) :
panel_sizer.Add(wx.StaticText(panel, -1, text), 0, wx.ALL, 5)
btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
show_btn = wx.Button(top_panel, -1, “Add widgets”)
self.Bind(wx.EVT_BUTTON, self.OnAdd, show_btn)
btn_sizer.Add(show_btn, 0, wx.ALL|wx.ALIGN_RIGHT, 5)
top_sizer.Add(btn_sizer, 0, wx.ALL|wx.ALIGN_RIGHT, 5)
self.panel_sizer = panel_sizer
self.panel = panel
self.top_panel = top_panel
self.top_sizer = top_sizer
self.panel_sizer.Layout()
self.panel.SetMinSize(self.panel.GetSize())
self.top_panel.SetMinSize(self.top_panel.GetSize())
self.reset_layout()
self.Refresh()
def OnAdd (self, event) :
for i in range(10) :
self.panel_sizer.Add(wx.StaticText(self.panel, -1, text), 0, wx.ALL, 5)
self.reset_layout()
def reset_layout (self) :
self.panel_sizer.Layout()
self.panel.SetupScrolling(scrollToTop=False)
self.top_sizer.Layout()
if name == “main” :
app = wx.App(0)
frame = MyFrame(None, -1, “Test”)
frame.Show()
app.MainLoop()