I have an application where I load a file and display its contents in hexadecimal. I display the bytes in a ScrolledWindow. I’ve gotten it to load everything up. The only issue is that the contents of the window are not visible until a scroll event. I’ve created (what I think is) a minimal example.
Anybody have any ideas why this is happening? How to get around it?
When I ran the code you uploaded the frame was empty. This was because the button was not added to bsizer and bsizer was not added to sizer.
After I fixed that, the button did appear and when I clicked on it, some data values immediately appeared in the scrolled window, without needing to scroll it.
Tested using wxPython 4.2.4 gtk3 (phoenix) wxWidgets 3.2.8 + Python 3.12.3 + Linux Mint 22.3.
Finally got it to work after consulting Google Gemini. Previosly, I tried Microsoft Copilot and Claude. Ended up switching to wx.lib.scrolledpanel.ScrolledPanel.
this is usually just a repaint/layout issue with wx.ScrolledWindow.
after you populate it, make sure you’ve called:
SetScrollRate(...)
Layout()
FitInside() (if using sizers)
and optionally Refresh() / Update()
also if you’re drawing manually, set SetVirtualSize() before showing the frame.
what’s happening is nothing triggers an initial paint, and the first scroll forces one — that’s why it suddenly appears. classic Scrolled Window Behaviour.