Python 练习实例32

感谢https://www.runoob.com/python/python-exercise-example64.html
题目:利用ellipse 和 rectangle 画图。

# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    from Tkinter import *
    canvas = Canvas(width = 400,height = 600,bg = 'white')
    left = 20
    right = 50
    top = 50
    num = 15
    for i in range(num):
        canvas.create_oval(250 - right,250 - left,250 + right,250 + left)
        canvas.create_oval(250 - 20,250 - top,250 + 20,250 + top)
        canvas.create_rectangle(20 - 2 * i,20 - 2 * i,10 * (i + 2),10 * ( i + 2))
        right += 5
        left += 5
        top += 10

    canvas.pack()
    mainloop()

以下为输出结果:
Python 练习实例32
Python 练习实例32

上一篇:java语言基础(一维数组练习):数组元素查找(查找指定元素第一次在数组中出现的索引)


下一篇:SENSORIK光栅EFS2000-11114