In Listing 12.4 the signature for the _draw method in line 19 should include a parameter to reference a turtle, since the turtle is in fact needed by the child classes.
def _draw(self, someTurtle):
print("error:…")
In Listing 12.4 the signature for the _draw method in line 19 should include a parameter to reference a turtle, since the turtle is in fact needed by the child classes.
def _draw(self, someTurtle):
print("error:…")
class Canvas:
def __init__(self,w,h):
self.width = w
self.height = h
self.visibleObjects = []
self.turtle = cTurtle.Turtle()
self.turtle.setup(width=self.width,height=self.height)
self.turtle.hideturtle()
def drawAll(self):
self.turtle.reset()
self.turtle.tracer(0)
for shape in self.visibleObjects:
shape._draw(self.turtle)
self.turtle.tracer(1)
self.turtle.hideturtle()
def addShape(self,shape):
self.visibleObjects.append(shape)
def draw(self,gObject):
gObject.setCanvas(self)
gObject.setVisible(True)
self.turtle.up()
self.turtle.tracer(0)
gObject._draw(self.turtle)
self.turtle.tracer(1)
self.addShape(gObject)