Week 7, ex 4.3
I don't get what i'm doing wrong
win = GraphWin("Tetrominoes", 150, 150)
point = Point(1, 1)
color = 'black'
def Block(Rectangle):
def __init__(self, point1, color = 'black'):
self.canvans = Rectangle(point, Point(point.x + 20, point.y + 20))
self.canvans.setFill(color)
def draw(self, win):
self.canvans.draw(win)
rect = Block(point)
rect.draw(win)
win.mainloop()
And result:
File "E:/Python/test1/Ex4.3.py", line 26, in
you want to define Block as a class, rather than a function: class Block: # no argument is needed here and then use either point or point1 consistantly between your self__init__ function and your rectangle definition.
Should the class not be derived from Rectangle? class Block(Rectangle): There its also a typo: canvans should be canvas. HTH.
Oh. I need more sleep. I had to write "class Block" instead of "def Block".
:-)
Join our real-time social learning platform and learn together with your friends!