0
我已經瀏覽了所有關於圓和python以及調用函數的問題,但沒有任何幫助。我也不能使用烏龜,所以請不要暗示。謝謝!從Python 3.6中的另一個函數調用循環函數Zelle Graphics
我想創建一個程序,用不同的顏色和半徑繪製同心圓(製作一個類似目標的圖像),但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()