Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.


+2 votes

below is my code for my final project. I am getting an error that says AttributeError: 'NoneType' object has no attribute 'draw'. I was wondering if anyone knows how to fix this

class Rectangles:
    #9 different squares will appear with the values 1-9
    def __init__(self, point1, point2, point3, point4):
        self.rectangle = Rectangle(Point(point1, point2), Point(point3, point4))
    def draw(self, win):
def setupRectangle():
    rect1 = Rectangles(0,900,100,400)

def main():
    win = GraphWin("Shut The Box",WINDOW_WIDTH, WINDOW_HEIGHT)
    rect = setupRectangle()

if __name__ == '__main__':
asked in CSC201 Spring 2021 by (2.3k points)
edited by

Note: edited question to use {} button to format it as code.

1 Answer

+3 votes

I think you'll want to return rect1 in setupRectangle, because right now rect doesn't equal anything, it only calls setupRectangle. That's why rect won't draw anything, because it doesn't equal anything.

answered by (4.8k points)