Jason Wang wrote:
I still can't make it work even if i added the
OnSize() method and attached the event, attached is my code.
The attachment didn't come through.
Also, i have another question, why does some of the code i read has
dc.BeginDrawing() and dc.EndDrawing()? Do i have to have that around
my Draw() method?
NO, you don't. Those calls once provided some optimization on some platforms, but I think they do nothing anywhere now. In any case, your code should work with or without them.
I also read the DoubleBufferedDrawing page, it is apparently a general
class which you can subclass and work with it, i didn't get it to
work,
Darn. Platform, Version? what "didn't work"
It's a pretty simple class really. It could well be useful to subclass, but was designed as a teaching example, more than anything.
> It looks pretty different from mine.
A little extra stuff, the but the basics are the same.
by the way, I find it's easiest to learn this stuff by adding things a little at a time. Your post said you were trying to learn about DCs. Why not start with a non-buffered example, so you can figure out the drawing first, then apply it to double buffering. About the easiest example I can come up with for drawing is:
#!/usr/bin/env python2.4
import wx
class DemoFrame(wx.Frame):
""" This window does some simple drawing """
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
dc = wx.PaintDC(self)
dc.SetPen(wx.BLACK_PEN)
dc.SetBrush(wx.RED_BRUSH)
dc.DrawRectangle(20,30, 100, 40)
app = wx.App()
frame = DemoFrame(None, size = (200, 200))
frame.Show()
app.MainLoop()
-Chris
···
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov