Hi all.
I have a FlexGridSizer in a ScrolledWindow derivative. I want it to
contain a variable number of rows which contain a custom widget
derived from wx.Panel (representing staves of a musical score). The
widget is to have variable height, and its width must fill all the
available space (if the space falls below a certain value, a
horizontal scrollbar should appear). If the total height of the
widgets is less than the available space, the last row should fill the
extra space. If it is less, the ScrolledWindow should show a scroll
bar so the user can, well, scroll up and down.
Sounds complex, I know, but I think I've gotten most of it figured
out. Thing is, I seem to be missing some magic word. Since the custom
widget's size at initialization is (-1,-1), all I get is the upper
left corners of the widgets. If I set the initial size to a greater
value, I get bigger parts of the widgets, but they do not expand in
either direction. If I use SetSize (in the widget's OnPaint method,
since that is, for now, where the height is determined), the widgets
become bigger, but are still placed on top of each other, as if they
had sizes of (-1,-1). How do I get the desired effect?
Derive from wx.PyPanel and override the DoGetBestSize method.
···
On 2/17/10 1:23 PM, egasimus wrote:
Hi all.
I have a FlexGridSizer in a ScrolledWindow derivative. I want it to
contain a variable number of rows which contain a custom widget
derived from wx.Panel (representing staves of a musical score). The
widget is to have variable height, and its width must fill all the
available space (if the space falls below a certain value, a
horizontal scrollbar should appear). If the total height of the
widgets is less than the available space, the last row should fill the
extra space. If it is less, the ScrolledWindow should show a scroll
bar so the user can, well, scroll up and down.
Sounds complex, I know, but I think I've gotten most of it figured
out. Thing is, I seem to be missing some magic word. Since the custom
widget's size at initialization is (-1,-1), all I get is the upper
left corners of the widgets. If I set the initial size to a greater
value, I get bigger parts of the widgets, but they do not expand in
either direction. If I use SetSize (in the widget's OnPaint method,
since that is, for now, where the height is determined), the widgets
become bigger, but are still placed on top of each other, as if they
had sizes of (-1,-1). How do I get the desired effect?
I've made some progress - it turns out that when I resize the window,
the contained widgets also resize - but they're always one event late.
What is it that is performed in the SIZE event that makes the layout
update? Doesn't seem to be Layout() or Fit().
···
On Feb 18, 10:52 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 2/17/10 1:23 PM, egasimus wrote:
Derive from wx.PyPanel and override the DoGetBestSize method.
--
Robin Dunn
Software Craftsmanhttp://wxPython.org