python练习题(三十一):用rectangle画方形
程序员文章站
2024-03-11 20:00:43
...
# 用rectangle画方形。
from tkinter import *
root = Tk()
root.title('rectangle')
canvas = Canvas(root, width=500, height=500, bg='yellow')
canvas.pack()
x0, y0, x1, y1 = 200, 200, 300, 300
for i in range(10):
canvas.create_rectangle(x0, y0, x1, y1, width=1)
x0 -= 15
y0 -= 15
x1 += 15
y1 += 15
mainloop()
运行结果: