- for i in xrange( len(coords) ):
- Canvas.AddText("%i"%(i),
- coords[i][0],
- coords[i][1],
- Size = 12,
- Position = "cc",
- BackgroundColor = "White")
- print "It took %s seconds to add the numbers"%(time.clock() - start)
-
-
-## ObjectList = []
-
-## print "Building a list of lots of random objects"
-## ## Random tests of everything:
-## def MakeRange():
-## while True:
-## Range = ( random.randint(BigRange[0],BigRange[1]), random.randint(BigRange[0],BigRange[1]) )
-## if abs (Range[0] - Range[1]) < 10:
-## continue
-## if Range[0] > Range[1]:
-## Range = ( Range[1], Range[0] )
-## break
-## return Range
-
-## # Rectangles
-## for i in range(300):
-## Range = MakeRange()
-## x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
-## lw = random.randint(1,5)
-## cf = random.randint(0,len(colors)-1)
-## h = random.randint(1, Range[1] - Range[0])
-## w = random.randint(1, Range[1] - Range[0])
-## ObjectList.append(FloatCanvas.Rectangle(x,y,h,w,LineWidth = lw,FillColor = colors[cf]))
-
-## # Ellipses
-## for i in range(300):
-## Range = MakeRange()
-## x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
-## lw = random.randint(1,5)
-## cf = random.randint(0,len(colors)-1)
-## h = random.randint(1, Range[1] - Range[0])
-## w = random.randint(1, Range[1] - Range[0])
-## ObjectList.append(FloatCanvas.Ellipse(x,y,h,w,LineWidth = lw,FillColor = colors[cf]))
-
-
-## # Circles
-## for i in range(500):
-## Range = MakeRange()
-## x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
-## D = random.randint(1, (Range[1] - Range[0]) / 2)
-## lw = random.randint(1,5)
-## cf = random.randint(0,len(colors)-1)
-## cl = random.randint(0,len(colors)-1)
-## ObjectList.append(FloatCanvas.Circle(x,y,D,LineWidth = lw,LineColor = colors[cl],FillColor = colors[cf]))
-## #ObjectList.append(FloatCanvas.Text("Circle # %i"%(i),x,y,Size = 12,BackgroundColor = None,Position = "cc"))
-
-## # Lines
-## for i in range(500):
-## Range = MakeRange()
-## points = []
-## for j in range(random.randint(2,100)):
-## point = (random.randint(Range[0],Range[1]),random.randint(Range[0],Range[1]))
-## points.append(point)
-## lw = random.randint(1,10)
-## cf = random.randint(0,len(colors)-1)
-## cl = random.randint(0,len(colors)-1)
-## ObjectList.append(FloatCanvas.Line(points, LineWidth = lw, LineColor = colors[cl]) )
-
-## # Polygons
-## for i in range(300):
-## Range = MakeRange()
-## points = []
-## for j in range(random.randint(2,60)):
-## point = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
-## points.append(point)
-## lw = random.randint(1,6)
-## cf = random.randint(0,len(colors)-1)
-## cl = random.randint(0,len(colors)-1)
-## ObjectList.append(FloatCanvas.Polygon(points,
-## LineWidth = lw,
-## LineColor = colors[cl],
-## FillColor = colors[cf],
-## FillStyle = 'Solid') )
-## random.shuffle(ObjectList)
-## print "Adding lots of random objects"
-## start = time.clock()
-## for Object in ObjectList:
-## Canvas.AddObject(Object)
-## print "It took %s Seconds to add %i objects "%(time.clock() - start, len(ObjectList) )
-
-## ## Pointset
-## for i in range(100):
-## points = []
-## points = RandomArray.uniform(Range[0],Range[1],(100,2))
-## cf = random.randint(0,len(colors)-1)
-## D = random.randint(1,4)
-## Canvas.AddPointSet(points, Color = colors[cf], Diameter = D)
-
-
-## # Scaled Text
-## String = "Scaled text"
-## for i in range(30):
-## ts = random.random()*3 + 0.2
-## cf = random.randint(0,len(colors)-1)
-## x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
-## Canvas.AddScaledText(String, x, y, Size = ts, Color = colors[cf], Position = "cc")
+ for Point in coords:
+ Canvas.AddPoint(Point, Diameter = 4)
+ print "It took %s seconds to add the points"%(time.clock() - start)
+ Canvas.ZoomToBB()
+
+ def PropertiesChangeTest(self,event=None):
+ wx.GetApp().Yield()
+
+ Range = (-10,10)
+ colors = self.colors
+
+ self.UnBindAllMouseEvents()
+ Canvas = self.Canvas
+
+ Canvas.ClearAll()
+ Canvas.SetProjectionFun(None)
+
+ self.ColorObjectsAll = []
+ self.ColorObjectsLine = []
+ self.ColorObjectsColor = []
+ self.ColorObjectsText = []
+ ##One of each object:
+ # Rectangle
+ x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ lw = random.randint(1,5)
+ cf = random.randint(0,len(colors)-1)
+ h = random.randint(1,5)
+ w = random.randint(1,5)
+ self.Rectangle = Canvas.AddRectangle(x,y,w,h,LineWidth = lw,FillColor = colors[cf])
+ self.ColorObjectsAll.append(self.Rectangle)
+
+ # Ellipse
+ x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ lw = random.randint(1,5)
+ cf = random.randint(0,len(colors)-1)
+ h = random.randint(1,5)
+ w = random.randint(1,5)
+ self.Ellipse = Canvas.AddEllipse(x,y,h,w,LineWidth = lw,FillColor = colors[cf])
+ self.ColorObjectsAll.append(self.Ellipse)
+
+ # Point
+ xy = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ D = random.randint(1,50)
+ lw = random.randint(1,5)
+ cf = random.randint(0,len(colors)-1)
+ cl = random.randint(0,len(colors)-1)
+ self.ColorObjectsColor.append(Canvas.AddPoint(xy, colors[cf], D))
+
+ # Circle
+ x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ D = random.randint(1,5)
+ lw = random.randint(1,5)
+ cf = random.randint(0,len(colors)-1)
+ cl = random.randint(0,len(colors)-1)
+ self.Circle = Canvas.AddCircle(x,y,D,LineWidth = lw,LineColor = colors[cl],FillColor = colors[cf])
+ self.ColorObjectsAll.append(self.Circle)
+
+ # Line
+ points = []
+ for j in range(random.randint(2,10)):
+ point = (random.randint(Range[0],Range[1]),random.randint(Range[0],Range[1]))
+ points.append(point)
+ lw = random.randint(1,10)
+ cf = random.randint(0,len(colors)-1)
+ cl = random.randint(0,len(colors)-1)
+ self.ColorObjectsLine.append(Canvas.AddLine(points, LineWidth = lw, LineColor = colors[cl]))
+
+ # Polygon
+## points = []
+## for j in range(random.randint(2,6)):
+## point = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+## points.append(point)
+ points = RandomArray.uniform(Range[0],Range[1],(6,2))
+ lw = random.randint(1,6)
+ cf = random.randint(0,len(colors)-1)
+ cl = random.randint(0,len(colors)-1)
+ self.ColorObjectsAll.append(Canvas.AddPolygon(points,
+ LineWidth = lw,
+ LineColor = colors[cl],
+ FillColor = colors[cf],
+ FillStyle = 'Solid'))
+
+ ## Pointset
+ points = RandomArray.uniform(Range[0],Range[1],(100,2))
+ cf = random.randint(0,len(colors)-1)
+ D = random.randint(1,4)
+ self.PointSet = Canvas.AddPointSet(points, Color = colors[cf], Diameter = D)
+ self.ColorObjectsColor.append(self.PointSet)
+
+ ## Point
+ point = RandomArray.uniform(Range[0],Range[1],(2,))
+ cf = random.randint(0,len(colors)-1)
+ D = random.randint(1,4)
+ self.Point = Canvas.AddPoint(point, Color = colors[cf], Diameter = D)
+ self.ColorObjectsColor.append(self.Point)
+
+ # Text
+ String = "Unscaled text"
+ ts = random.randint(10,40)
+ cf = random.randint(0,len(colors)-1)
+ x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ self.ColorObjectsText.append(Canvas.AddText(String, x, y, Size = ts, Color = colors[cf], Position = "cc"))
+
+ # Scaled Text
+ String = "Scaled text"
+ ts = random.random()*3 + 0.2
+ cf = random.randint(0,len(colors)-1)
+ x,y = (random.uniform(Range[0],Range[1]),random.uniform(Range[0],Range[1]))
+ self.ColorObjectsText.append(Canvas.AddScaledText(String, x, y, Size = ts, Color = colors[cf], Position = "cc"))
+
+ # A "Button"
+ Button = Canvas.AddRectangle(-10, -12, 20, 3, LineStyle = None, FillColor = "Red")
+ Canvas.AddScaledText("Click Here To Change Properties",
+ 0, -10.5,
+ Size = 0.7,
+ Color = "Black",
+ Position = "cc")
+
+ Button.Bind(FloatCanvas.EVT_FC_LEFT_DOWN, self.ChangeProperties)