I’ve got a ScrolledPanel whose children I do not want to grow past the visual width of the panel, but I do want to allow them to be scrolled vertically. (I believe that is to say, I want its virtual width to match its client width?) However, disabling horizontal scroll doesn’t seem to stop sizers from giving items as much horizontal space as they want. Is there some method to do this that I’m not seeing and/or event handling trickery to do this?
I've got a ScrolledPanel whose children I do not want to grow past the
visual width of the panel, but I do want to allow them to be scrolled
vertically. (I believe that is to say, I want its virtual width to match
its client width?) However, disabling horizontal scroll doesn't seem to
stop sizers from giving items as much horizontal space as they want. Is
there some method to do this that I'm not seeing and/or event handling
trickery to do this?
In the attached file, the text will wordwrap to the size of the frame in a Panel, but not in a ScrolledPanel. I presume that’s because the text widget was only given as much horizontal space as the frame had for the panel, but given unlimited for the scrolled panel. I would like the scrolled panel to followthe panel’s behavior for horizontal space.
It's because the ScrolledPanel is setting the virtual size based on the minimum size calculated by the sizer, and that is based on the best size reported by the static text. So since the best size of a static text is based on how much space it takes to show the text without wrapping then that is what you get. Passing scroll_x=False just means don't show that scrollbar, it has nothing to do with the virtual size of the scrolled window or the layout of the widgets.
You can try resetting the virtual size of the scrolled panel, although it wasn't designed with that in mind so there may be some glitches. You can set the min width of the static text to be your desired width, then the sizer will use that value instead of the best width. Or you can use wx.ScrolledWindow instead of ScrolledPanel, and set the virtual size and etc. how you prefer it.
···
On 5/19/12 8:14 AM, Steven Wallace wrote:
In the attached file, the text will wordwrap to the size of the frame in
a Panel, but not in a ScrolledPanel. I presume that's because the text
widget was only given as much horizontal space as the frame had for the
panel, but given unlimited for the scrolled panel. I would like the
scrolled panel to followthe panel's behavior for horizontal space.