I’ve got a fairly complex frame with panels and sizers, including a ScrolledPanel. The issue is that on Mac I can see the scroll bar, but on Windows it simply doesn’t work.
The code is the same, see below:
import wx
import wx.lib.scrolledpanel
class MyFrame(wx.Frame):
def __init__(self, *args, **kw):
super(MyFrame, self).__init__(*args, **kw, size=app_size)
self._panel = wx.Panel(self)
self._vbox = wx.BoxSizer(wx.VERTICAL)
self._sb = wx.StaticBox(self._panel)
self._sbs = wx.StaticBoxSizer(self._sb, orient=wx.VERTICAL)
self._panel.SetSizer(self._sbs)
# buttons
self._h_box_buttons = wx.BoxSizer(wx.HORIZONTAL)
self._quitButton = wx.Button(self, label='Quit')
self._h_box_buttons.Add(self._quitButton, flag=wx.ALIGN_LEFT)
self._quitButton.Bind(wx.EVT_BUTTON, self.on_close)
self._vbox.Add(self._panel, proportion=1, flag=wx.ALL|wx.EXPAND, border=5)
self._vbox.Add(self._h_box_buttons,
flag=wx.ALIGN_CENTER|wx.TOP|wx.BOTTOM|wx.ALL|wx.EXPAND, border=10)
self.SetSizer(self._vbox)
self.InitUI()
def InitUI(self):
msg = "Welcome to my scroll test!"
self.showMessage(msg)
self.s_p = wx.lib.scrolledpanel.ScrolledPanel(self, -1, size=(575, 100), style=wx.SIMPLE_BORDER)
self.s_p.SetupScrolling()
self.s_sizer = wx.BoxSizer(wx.VERTICAL)
self.s_p.SetSizer(self.s_sizer)
self._sbs.Add(self.s_p)
for idx in range(1, 20):
msg = "Line: " + str(idx)
t = wx.StaticText(self.s_p, label=msg)
self.s_sizer.Add(t)
msg = "That's a wrap folks..."
self.showMessage(msg)
def showMessage(self, msg):
t = wx.StaticText(self._panel, label=msg)
self._sbs.Add(t)
self._sbs.AddSpacer(10)
def on_close(self, e):
self.Close(True)
# Run the program
if __name__ == "__main__":
app = wx.App()
app_size = (600, 700)
ex = MyFrame(None)
ex.Show()
app.MainLoop()