unwanted extra height in scrolledpanel within comboPopup

I am trying to create a custom control using the wx.combo.ComboPopup;
in this case, what I would like to pop up (really, drop down) is a
scrolledPanel that holds a column of a variable number of text controls. [wxPython 2.8.10 or 2.9.x, Python 2.5 or 2.7, Windows XP].

If there are only a smallish number of text controls, I would
like the height of the popup to be exactly enough to hold all of them—no taller
or shorter.

If there are many text controls, I would like the popup’s height to clip at a maximum height, like ~500px. And then, in order to see the
remainder of the text controls, there will appear scroll bars to allow scrolling
down the column.

I almost have this, but there is an annoying visual
glitch:

If I use the scrolledPanel and call SetupScrolling() once all text controls are added, it
works other than this: there is a small bit of extra space at the end of the
column of text controls.

In order to see this, please run the attached “Small Runnable
Sample App”. Pop open the combo and scroll down
to the very bottom. See that red bit?

The question is: why
is the scrolledpanel (in red) showing through and how can I have that not
happen?

(I have fooled around with how I set the pref_height of the
popup but no matter what I try, so far I am never getting it to not show at
least some red).

Many thanks,

Che

testing_combo_list_with_scrolled.py (2.72 KB)

This is a side-effect of how wx.ScrolledWindow (the base class of ScrolledPanel) works. ScrolledWindows have both virtual size and scroll rate (among others) attributes that are used to define the scrolling. The scroll rate is how many pixels the content is scrolled when the scrollbar's arrow widgets are clicked, this is also called scroll units. The virtual size will always be rounded up to the next multiple of the scroll units because the ScrolledWindow is not able to deal with a fractional unit. If the virtual size is not rounded up then you have the problem of not being able to scroll far enough to see all of the content. By rounding up you can see all of it, plus an extra 0 to scrollRate-1 pixels. Being able to see too much in this case is better than not being able to see enough.

If being able to use an exact amount of virtual size that is not rounded up is important to you then you can try using wx.VScrolledWindow instead.

···

On 11/9/12 1:23 PM, C M wrote:

I am trying to create a custom control using the wx.combo.ComboPopup; in
this case, what I would like to pop up (really, drop down) is a
scrolledPanel that holds a column of a variable number of text
controls. [wxPython 2.8.10 or 2.9.x, Python 2.5 or 2.7, Windows XP].

If there are only a smallish number of text controls, I would like the
height of the popup to be exactly enough to hold all of them�no taller
or shorter.

If thereare many text controls, I would like the popup's height to clip
at a maximum height, like ~500px.And then, in order to see the remainder
of the text controls, there will appear scroll bars to allow scrolling
down the column.

I *almost* have this, but there is an annoying visual glitch:

If I use the scrolledPanel and call SetupScrolling() once all text
controls are added, it works other than this: there is a small bit of
extra space at the end of the column of text controls.

In order to see this, please run the attached "Small Runnable Sample
App".Pop open the combo and scroll down to the very bottom.See that red bit?

The question is:why is the scrolledpanel (in red) showing through and
how can I have that not happen?

--
Robin Dunn
Software Craftsman