+ 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(wx.Pen("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(wx.SOLID)
+ 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(wx.Notebook):
+ def __init__(self, parent, id, log):
+ style = wx.NB_BOTTOM
+
+ if wx.Platform == "__WXMAC__":
+ style = 0
+
+ wx.Notebook.__init__(self, parent, id, style=style)
+ self.log = log
+
+ # Initialize our various samples and add them to the notebook.
+ 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 used for all the various sample pages; the mechanics are the same
+# for each one with regards to the notebook. The only difference is
+# the function we use to draw on it.
+class DrawPanel(wx.Panel):
+ def __init__(self, parent, drawFun, log):
+ wx.Panel.__init__(self, parent, -1)
+ self.SetBackgroundColour(wx.WHITE)
+
+ self.log = log
+ self.drawFun = drawFun
+ self.Bind(wx.EVT_PAINT, self.OnPaint)
+
+
+ def OnPaint(self, evt):
+ dc = wx.PaintDC(self)
+ dc.Clear()
+ self.drawFun(dc,self.log)
+