- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex57.py
More file actions
Latest commit
22 lines (21 loc) · 562 Bytes
/
Copy pathex57.py
File metadata and controls
22 lines (21 loc) · 562 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'''
画图,学用line画直线。
(画出回形图案)
'''
importtkinterastk
canvas=tk.Canvas(width=500, height=500, bg='green')
canvas.pack()
x0, y0=50, 50
l, d=400, 5
whilel>=d:
l-=d
canvas.create_line(x0, y0, x0+l, y0)
l-=d
canvas.create_line(x0+l+d, y0, x0+l+d, y0+l+2*d)
l-=d
canvas.create_line(x0+l+2*d, y0+l+3*d, x0+2*d, y0+l+3*d)
l-=d
canvas.create_line(x0+2*d, y0+l+4*d , x0+2*d, y0+2*d)
x0+=2*d
y0+=2*d
canvas.mainloop()