我的代码有点问题,基本上我需要创建图像中显示的模式
使用graphics
John Zelle 教授编写的模块(可在此处获得)。
这是 10 条直线,需要根据用户选择在不同大小的画布中创建它。所以我决定循环它并在每行之间添加额外的空间,但是当我执行循环时,我得到一个错误,说这条线已经被绘制了,有人知道如何避免这种情况吗?
from graphics import *
def Main():
valid = False
while not valid:
sizeInput= eval(input("PLease select a size, 7, 9, 11: "))
if sizeInput == 7 or sizeInput == 9 or sizeInput == 11 :
size= sizeInput*100
valid=True
else:
print("Invalid Number")
Draw(size)
def Draw(size):
win = GraphWin("Pat1",size,size)
PointX= Point(0,0)
PointY= Point(700,70)
line = Line(PointX,PointY)
i = 0
while i<10:
line.draw(win)
PointX.x+70
PointY.y+70
i=i+1