100-058
画图,学用rectangle画方形。
1 #! /usr/bin/env python 2 # -*- coding:utf-8 -*- 3 ''' 4 画图,学用rectangle画方形。 5 ''' 6 if __name__ == '__main__': 7 from tkinter import * 8 9 root = Tk() 10 root.title('Canvas') 11 canvas = Canvas(root, width=400, height=400, bg='blue') 12 x0 = 263 13 y0 = 263 14 y1 = 275 15 x1 = 275 16 for i in range(19): 17 canvas.create_rectangle(x0, y0, x1, y1) 18 x0 -= 5 19 y0 -= 5 20 x1 += 5 21 y1 += 5 22 23 canvas.pack() 24 root.mainloop()
浙公网安备 33010602011771号