Hello,
Leaning on "wxPython in Action", I now have code to draw a graph on a buffer.
For some reason though, while it doesn't do this on Linux, on Windows, the
buffer isn't clearing itself on each paint event like I'd like, so remnants of
previous drawings are present after a resize.
def OnPaint(self, event):
"""Paint the window. We call InitBuffer here each time to detect the
current size of the drawing area."""
self.InitBuffer()
dc = wx.BufferedPaintDC(self, self.buffer)
def InitBuffer(self):
"""Initialize the buffer, and draw the lines on it."""
size = self.GetClientSize()
self.buffer = wx.EmptyBitmap(size.width, size.height)
dc = wx.BufferedDC(None, self.buffer)
dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
dc.SetFont(self.defaultFont)
dc.Clear()
self.leftMargin = int(self.leftMarginFactor*size.width)
self.bottomMargin = int(size.height -
self.bottomMarginFactor*size.height)
self.rightMargin = int(size.width - self.rightMarginFactor*size.width)
self.topMargin = int(self.topMarginFactor*size.height)
self.DrawLabels(dc)
self.DrawAxes(dc)
self.DrawLines(dc)
self.reInitBuffer = False
I suspect that the drawing itself is unimportant, I can only assume that I'm
missing a critical wiping of the previous graphics context. Some help
appreciated.
Thanks,
Mike
···
--
Michael P. Soulier <msoulier@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein