I have started to explore wxPython.
Currently I have problems with this code:
Platform linux/wxGTK (wxPython 4.01)
Action:
Add Elements with the ‘+ Add’ Button
Expected behavior:
Wrap around horizontally if necessary
Show Vertical Scrollbar if necessary
Render each Element inside the visible/scrollable Area
Current behavior:
if the window is very wide, elements are rendered off-screen
no scrollbars are shown
the code is generated with wxGlade.
I tried to workaround the problem by Setting the virtualsize in the OnSize and AddCard functions.
The debug print agree that size and virtualsize are the same, but the Panels are not rendered properly.
I’ve tried the WrapSizer on a SrolledWindow with thumbnails trying to imitate the MS explorer on an image folder: when one narrows the frame the thumbnails are wrapped around (though not as smoothly as Windows does), but when one widens the frame again there is no unwrapping, i.e. in Windows as soon as there is enough room for a single thumbnail the whole rearranges. Once one has actually seen it one can imagine the quality of that explorer!
But all the other sizers seem to be nice & robust (and certainly not only them !!!)
My on_size handler above does exactly this. It will unwrap when you increase the width. I have tested only on Windows, but I don’t see why it should not work on other platforms as well.
That’s true, it just deviates from the behaviour of a sizer. But maybe that’s intended on performance reasons because when one saves the frame size and starts it again with that size then it sizes properly to that new size. For my application that’s dynamical enough
just one remark: with the explorer on Windows one never sees the horizontal scrollbar which is actually not needed; on your example it’s flickering and if one stops at the right time it becomes visible; style=wx.VSCROLL on the ScrolledWindow won’t work but ShowScrollbars does;
what I now would like is this vanishing narrow bar what even the explorer hasn’t grown up to yet
I’m on the same platform
the different event handler doesn’t matter on my Windows, but I forgot to take your second binding out again, it’s not needed…
in your coding the horizontal scroll bar comes up when the frame is horizontally narrowed up to the last two columns
in my example (just one post up) there is no ‘EVT_SIZE’ at all: there is just a ‘ScrolledWindow’ and in it a ‘WrapSizer’! the mechanics are all done by the magic of wx (I hope)