anonymous
  • anonymous
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 rect.canvans.draw(win) AttributeError: 'NoneType' object has no attribute 'canvans'
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
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.
andrew.m.higgs
  • andrew.m.higgs
Should the class not be derived from Rectangle? class Block(Rectangle): There its also a typo: canvans should be canvas. HTH.
anonymous
  • anonymous
Oh. I need more sleep. I had to write "class Block" instead of "def Block".

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

andrew.m.higgs
  • andrew.m.higgs
:-)

Looking for something else?

Not the answer you are looking for? Search for more explanations.