Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Harrison Court
4,232 PointsPython: function takes at most 4 arguments (5 given)
Hello there! I'm having a slight issue with my code. I have made a program where it can draw things onto a pygame canvas. However, I am getting the error (Stated in the title) and I have no clue how to fix it.
class drawing:
def __init__(self):
# Rect. Dimensions
self.dimensionWidth = 0
self.dimensionLength = 0
# Circle Dimensions
self.dimensionRadius = 0
def drawRect(self):
pygame.draw.rect(screen, (0,0,0), (250,250), self.dimensionWidth, self.dimensionRadius)
pygame.display.update()
def drawCircle(self):
pygame.draw.circle(screen, (0,0,0), (250,250), self.dimensionRadius, self.dimensionRadius)
# Rectangle Creation Window
def rectCreationWindow():
drawingClass = drawing()
# Create the window.
objWindow = Tk()
objWindow.wm_title("Rect. Creation Window")
objWindow.geometry("200x75")
# Width
widthEntry = Entry(objWindow)
widthEntry.pack()
widthEntry.focus_set()
# Length
lengthEntry = Entry(objWindow)
lengthEntry.pack()
lengthEntry.focus_set()
drawing.dimensionWidth = widthEntry.get()
drawing.dimensionLength = lengthEntry.get()
createObjButton = tk.Button(objWindow, text ='Create Object', command=drawingClass.drawRect)
pygame.display.update()
createObjButton.pack()
objWindow.mainloop()
def circleCreationWindow():
drawingClass = drawing()
# Create the window.
objWindow = Tk()
objWindow.wm_title("Circle Creation Window")
objWindow.geometry("200x75")
# Radius
radiusEntry = Entry(objWindow)
radiusEntry.pack()
radiusEntry.focus_set()
drawing.dimensionRadius = radiusEntry.get()
createObjButton = tk.Button(objWindow, text ='Create Circle', command=drawingClass.drawCircle)
pygame.display.update()
createObjButton.pack()
objWindow.mainloop()
1 Answer

Steven Parker
227,167 PointsI'm not a "pygame" user, but when I looked up the documentation for pygame.draw.rect(), it says it takes 4 arguments:
rect(Surface, color, Rect, width=0)
But this code is passing it 5:
pygame.draw.rect(screen, (0,0,0), (250,250), self.dimensionWidth, self.dimensionRadius)
I'm guessing rectangles probably don't have radiuses.