Python 练习实例48

版权声明:版权所有,转载请注明链接! https://blog.csdn.net/qq_43558971/article/details/91404440

首先感谢:https://www.runoob.com/python/python-exercise-example58.html
题目:画图,学用rectangle画方形。

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
if __name__ == '__main__':
    from Tkinter import *
    root = Tk()
    root.title('Canvas')
    canvas = Canvas(root,width = 400,height = 400,bg = 'yellow')
    x0 = 263
    y0 = 263
    y1 = 275
    x1 = 275
    for i in range(19):
        canvas.create_rectangle(x0,y0,x1,y1)
        x0 -= 5
        y0 -= 5
        x1 += 5
        y1 += 5
        
    canvas.pack()
    root.mainloop()

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_43558971/article/details/91404440