python练习题(三十一):用rectangle画方形

# 用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()

运行结果:
在这里插入图片描述

发布了37 篇原创文章 · 获赞 0 · 访问量 402

猜你喜欢

转载自blog.csdn.net/yizhishuixiong/article/details/104966992