Can someone help me with this code.. I get an error when I try to execute it

from graphics import *
 
def main():
    colour = raw_input("Enter the colour: ")
    win = GraphWin("Patch", 200, 200)
    drawCircle(win, 50, 50, colour)

def drawCircle(win, x, y, colour):
    for i in range(5):
        for j in range(5):
            if (i + j) % 2 == 0:
                topLeftX = x + i * 20
                topLeftY = y + j * 20
                circle = Circle(Point(topLeftX, topLeftY),
                                      Point(topLeftX + 20, topLeftY + 20))
                circle.setFill(colour)
                circle.draw(win)
                
main()

Recommended Answers

All 3 Replies

What error do you get?

What error do you get?

Traceback (most recent call last):
File "C:/Documents and Settings/Compaq_Owner/Desktop/0", line 19, in <module>
main()
File "C:/Documents and Settings/Compaq_Owner/Desktop/0", line 6, in main
drawCircle(win, 50, 50, colour)
File "C:/Documents and Settings/Compaq_Owner/Desktop/0", line 15, in drawCircle
Point(topLeftX + 20, topLeftY + 20))
File "C:\Python26\lib\site-packages\graphics.py", line 611, in __init__
p1 = Point(center.x-radius, center.y-radius)
TypeError: unsupported operand type(s) for -: 'int' and 'instance'

The correct arguments for Circle() are (center_point, radius) and you gave two points.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.