I have written a program that uses a wxScrolledWindow, with a "world"
that can not
fit entirely in the window.
If I scroll the window as the first action, the screen doesn't get redrawn,
but rather is erased as it moves out of view and back. As soon as I resize
the window, everything is fine: I can scroll the window and the view
moves as one would expect. Here's a snapshot of what I do:
class WorldGUI(wxScrolledWindow):
def __init__(self, parent, id = -1, size = wxDefaultSize):
wxScrolledWindow.__init__(self, parent, id, (0, 0), size=size,
style=wxSUNKEN_BORDER)
[snip]
def SetEvents(self):
EVT_PAINT(self, self.OnPaint) # wxPython 2.4
# the window resize event and idle events for managing the buffer
wx.EVT_SIZE(self, self.OnSize)
wx.EVT_IDLE(self, self.OnIdle)
wx.EVT_SCROLL(self, self.OnScroll)
def OnSize(self, event=None):
self.reInitBuffer = True
def OnScroll(self, event=None):
self.reInitBuffer = True
# Note: it doesn't force a redraw the same way OnSize do!!!
def OnIdle(self, event=None):
if self.reInitBuffer:
self.InitBuffer()
self.Refresh(False)
self.reInitBuffer = False
def InitBuffer(self):
if USE_BUFFERED_DC: # For Windows XP
# Initialize the buffer bitmap.
self.buffer = wxEmptyBitmap(self.maxWidth, self.maxHeight)
dc = wxBufferedDC(None, self.buffer)
dc.SetBackground(wxBrush(self.GetBackgroundColour()))
dc.Clear()
self.DoDrawing(dc)
else:
[snip]
Any hint would be appreciated!
André