Sample app below. There are two problems:
-
The inner scrolledpanel starts off with a size of (0,0). I could call SetMinSize, and in fact that’s the workaround I ended up using in my app, and it doesn’t stop the frame from being resized to less than the minimum panel size unless I call SetMinSize on the frame too. This ends up working, I guess, but it’s messy.
-
Those buttons are supposed to be aligned to the right, and stay on the right as the window is resized. I have no idea why this isn’t happening, but leaving out the scrolledpanel makes no difference, FWIW.
Any suggestions?
thanks,
Nat
import wx, wx.lib.scrolledpanel
class MyFrame (wx.Frame) :
def init (self, *args, **kwds) :
wx.Frame.init(self, *args, **kwds)
frame_sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(frame_sizer)
top_panel = wx.Panel(self)
top_sizer = wx.BoxSizer(wx.VERTICAL)
top_panel.SetSizer(top_sizer)
frame_sizer.Add(top_panel, 1, wx.ALL|wx.EXPAND|wx.ALIGN_RIGHT)
panel = wx.lib.scrolledpanel.ScrolledPanel(top_panel, -1, style=wx.SUNKEN_BORDER)
top_sizer.Add(panel, 1, wx.ALL|wx.EXPAND)
panel_sizer = wx.BoxSizer(wx.VERTICAL)
panel.SetSizer(panel_sizer)
for i in range(20) :
panel_sizer.Add(wx.StaticText(panel, -1, “Hello, world!”), 0, wx.ALL, 5)
btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
btn_sizer.Add(wx.Button(top_panel, wx.ID_CANCEL), 0, wx.ALL|wx.ALIGN_RIGHT, 5)
btn_sizer.Add(wx.Button(top_panel, wx.ID_OK), 0, wx.ALL|wx.ALIGN_RIGHT, 5)
top_sizer.Add(btn_sizer, 0, wx.ALL|wx.EXPAND|wx.ALIGN_RIGHT, 5)
panel_sizer.Fit(panel)
top_sizer.Fit(top_panel)
panel.SetupScrolling(scrollToTop=False)
self.Fit()
if name == “main” :
app = wx.App(0)
frame = MyFrame(None, -1, “Test”)
frame.Show()
app.MainLoop()