+ log.write("DrawTime: %s seconds with DrawRectangleList and Numpy Array\n" % (time.time() - start))
+ except ImportError:
+ log.write("Couldn't import Numeric")
+ pass
+
+
+def TestRectanglesLoop(dc,log):
+ dc.BeginDrawing()
+
+ start = time.time()
+ dc.DrawRectangleList(rectangles,pens,brushes)
+ log.write("DrawTime: %s seconds with DrawRectanglesList\n" % (time.time() - start))
+
+ start = time.time()
+ for i in range(len(rectangles)):
+ dc.SetPen( pens[i] )
+ dc.SetBrush( brushes[i] )
+ dc.DrawRectangle(rectangles[i][0],rectangles[i][1],rectangles[i][2],rectangles[i][3])
+ dc.EndDrawing()
+ log.write("DrawTime: %s seconds with Python loop\n" % (time.time() - start))
+
+
+def TestPolygons(dc,log):
+ dc.BeginDrawing()
+
+ start = time.time()
+ dc.SetPen(wxPen("BLACK", 1))
+ dc.DrawPolygonList(polygons)
+ dc.DrawPolygonList(polygons,pens)
+ dc.DrawPolygonList(polygons,pens[0],brushes)
+ dc.DrawPolygonList(polygons,pens,brushes[0])
+ dc.DrawPolygonList(polygons,None,brushes)
+ log.write("DrawTime: %s seconds with DrawPolygonList\n" % (time.time() - start))
+
+ dc.EndDrawing()
+
+
+def TestText(dc,log):
+ dc.BeginDrawing()
+
+ start = time.time()
+
+ # NOTE: you need to set BackgroundMode for the background colors to be used.
+ dc.SetBackgroundMode(wxSOLID)
+ foreground = colors1
+ background = colors2
+ dc.DrawTextList(text, points, foreground, background)
+
+ log.write("DrawTime: %s seconds with DrawTextList\n" % (time.time() - start))
+
+ dc.EndDrawing()
+
+
+
+class TestNB(wxNotebook):
+ def __init__(self, parent, id, log):
+ style = wxNB_BOTTOM
+ if wxPlatform == "__WXMAC__":
+ style = 0
+ wxNotebook.__init__(self, parent, id, style=style)
+ self.log = log
+
+ win = DrawPanel(self, TestEllipses, log)
+ self.AddPage(win, 'Ellipses')
+
+ win = DrawPanel(self, TestText, log)
+ self.AddPage(win, 'Text')
+
+ win = DrawPanel(self, TestPolygons, log)
+ self.AddPage(win, 'Polygons')
+
+ win = DrawPanel(self, TestPoints, log)
+ self.AddPage(win, 'Points')
+
+ win = DrawPanel(self, TestLines, log)
+ self.AddPage(win, 'Lines')
+
+ win = DrawPanel(self, TestRectangles, log)
+ self.AddPage(win, 'Rectangles')
+
+
+class DrawPanel(wxPanel):
+ def __init__(self, parent, drawFun, log):
+ wxPanel.__init__(self, parent, -1)
+ self.SetBackgroundColour(wxWHITE)
+
+ self.log = log
+ self.drawFun = drawFun
+ EVT_PAINT(self, self.OnPaint)
+
+
+ def OnPaint(self, evt):
+ dc = wxPaintDC(self)
+ dc.Clear()
+ self.drawFun(dc,self.log)
+