Puzzling resize behaviour

I've got a wxScrolledWindow whose contents are
organized with a sizer. One of the sizer items is a
wxPanel which has a child control (wxSpinCtrl) set at
a fixed location within the wxPanel (i.e. no sizers
within the wxPanel).

If the wxScrolledWindow is scrolled down and the
wxFrame is resized such that the scroll changes, then
the location of the wxSpinCtrl changes WITHIN the
wxPanel.

I suppose I can compensate for this by catching the
resize and repositioning the wxSpinCtrl each time, but
it looks like a bug to me. Any ideas?

If you'd like to try it out, here is a working code
snippet: http://pastie.textmate.org/72790

Run the program, shrink down the frame until the
scroll bar appears, scroll down to the bottom and then
resize the frame back out. The wxSpinCtrl moves up
within the wxPanel.

Windows XP
Python 2.4.3
wxPython ANSI-2.8.4.0

Gre7g

···

____________________________________________________________________________________
Need Mail bonding?
Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
http://answers.yahoo.com/dir/?link=list&sid=396546091

Gre7g Luterman wrote:

I've got a wxScrolledWindow whose contents are
organized with a sizer. One of the sizer items is a
wxPanel which has a child control (wxSpinCtrl) set at
a fixed location within the wxPanel (i.e. no sizers
within the wxPanel).

If the wxScrolledWindow is scrolled down and the
wxFrame is resized such that the scroll changes, then
the location of the wxSpinCtrl changes WITHIN the
wxPanel.

I suppose I can compensate for this by catching the
resize and repositioning the wxSpinCtrl each time, but
it looks like a bug to me. Any ideas?

Looks like maybe one of the pos/size optimizations in wxMSW is going haywire. I noticed that it doesn't happen every time, and that the virtual size of the scrolled window can be inaccurate at startup. Making this change seems to fix it for me. Instead of using SetSizerAndFit, do this:

         self.ScrollWin.SetSizer(self.Sizer)
         wx.CallAfter(self.ScrollWin.FitInside)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

The SetSizerAndFit() example was just that, an example
to illustrate the bug with a minimum of code to pore
through. My actual code uses XRC, so there is no
SetSizerAndFit() call made explicitly.

I worked around this in my app. by resetting item
positions during a resize, but it is undenyably a
Kludge and it causes more screen flicker than I think
is really needed.

Gre7g

____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.

···

--- Robin Dunn <robin@alldunn.com> wrote:

Looks like maybe one of the pos/size optimizations
in wxMSW is going
haywire. I noticed that it doesn't happen every
time, and that the
virtual size of the scrolled window can be
inaccurate at startup.
Making this change seems to fix it for me. Instead
of using
SetSizerAndFit, do this:

         self.ScrollWin.SetSizer(self.Sizer)
         wx.CallAfter(self.ScrollWin.FitInside)