Still having problem scrolling sub-windows

OK, back with some more question concerning wx.ScrolledWindow and the SetTargetWindow() method. I'm having problems getting my OnPaint code to draw correctly when I'm within a sub-window. (code attached)

In the simple example, I'm drawing a simple grid using the self.CalcUnscrolledPosition(0, 0) and self.GetUpdateRegion() methods to figure out what area of the window need re-painting and drawing my grid for that regnion only.

However, as soon as I stick that same window in a sizer to get my tri-pane layout, and re-direct the scrollbar from the parent window down to my canvas, the OnPaint code stops working correctly. Unless I'm doing something wrong (which is entirely possible) It seems that the SetTargetWindow code doesn't set the start of the sub-window correctly.

I'm using wxPython 2.4.2.4u and Python 2.3

oO

scrolledCanvas.py (8.95 KB)

···

--
Olivier Ozoux

Ozu's Mail Robot wrote:

OK, back with some more question concerning wx.ScrolledWindow and the SetTargetWindow() method. I'm having problems getting my OnPaint code to draw correctly when I'm within a sub-window. (code attached)

In the simple example, I'm drawing a simple grid using the self.CalcUnscrolledPosition(0, 0) and self.GetUpdateRegion() methods to figure out what area of the window need re-painting and drawing my grid for that regnion only.

However, as soon as I stick that same window in a sizer to get my tri-pane layout, and re-direct the scrollbar from the parent window down to my canvas, the OnPaint code stops working correctly. Unless I'm doing something wrong (which is entirely possible) It seems that the SetTargetWindow code doesn't set the start of the sub-window correctly.

No it doesn't. The target window needs to get the view start and etc. from the window that is managing the scrolling. In your first case that is itself, but in the second case it is the parent.

···

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