-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmm.py
43 lines (43 loc) · 1.28 KB
/
mmm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import turtle
def main():
filename=input("please enter drawing filename: ")
t=turtle.Turtle()
screen=t.getscreen()
file=open(filename,"r")
for line in file:
text=line.strip()
commandList=text.split(",")
command=commandList[0]
if command=="goto":
x=float(commandList[1])
y=float(commandList[2])
width=float(commandList[3])
color=commandList[4].strip()
t.width(width)
t.pencolor(color)
t.goto(x,y)
elif command=="circle":
radius=float(commandList[1])
width=float(commandList[2])
color=commandList[3].strip()
t.width(width)
t.pencolor()
t.circle(radius)
elif command=="beginfill":
color=commandList[1].strip()
t.fillcolor(color)
t.begin_fill()
elif command=="endfill":
t.end_fill()
elif command=="penup":
t.penup()
elif command=="pendown":
t.pendown()
else:
print("unknown command found in file:",command)
file.close()
t.ht()
turtle.mainloop()
print("program execution Completed ")
if __name__=="__main__":
main()