Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

lojs0

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 <module> rect.canvans.draw(win) AttributeError: 'NoneType' object has no attribute 'canvans'

  • one year ago
  • one year ago

  • This Question is Closed
  1. snark
    Best Response
    You've already chosen the best response.
    Medals 1

    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.

    • one year ago
  2. andrew.m.higgs
    Best Response
    You've already chosen the best response.
    Medals 0

    Should the class not be derived from Rectangle? class Block(Rectangle): There its also a typo: canvans should be canvas. HTH.

    • one year ago
  3. lojs0
    Best Response
    You've already chosen the best response.
    Medals 0

    Oh. I need more sleep. I had to write "class Block" instead of "def Block".

    • one year ago
  4. andrew.m.higgs
    Best Response
    You've already chosen the best response.
    Medals 0

    :-)

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.