我已经看了所有关于圆、python和调用函数的问题,没有任何帮助。我也不能用乌龟,所以请不要这样建议。谢谢您!在
我试图创建一个程序,绘制不同颜色和半径的同心圆(以生成类似目标的图像),但drawCircle函数需要从main()调用,并且它必须具有特定的参数。我可以单独运行这些函数,但不能一起运行。图形窗口显示标题和设置的背景颜色,但没有圆圈。我调用drawCircle函数的方式有错误吗?在from graphics import *
def drawCircle(win,centerPoint,radius,color):
circ = Circle(centerPoint,radius)
circ.setFill(color)
circ.setOutline(color)
circ.draw(win)
def main():
win = GraphWin("Target", 600, 600)
win.setCoords(-6,-6,6,6)
win.setBackground("brown")
centerPoint = Point(300, 300)
for i in range(6):
W = drawCircle(win,centerPoint,250,"white")
Bk = drawCircle(win,centerPoint,200,"black")
Bl = drawCircle(win,centerPoint,150,"dark blue")
R = drawCircle(win,centerPoint,100,"dark red")
Y = drawCircle(win,centerPoint,50,"yellow")
win.getMouse()
win.close()
main()