#圆
from tkinter import *
canvas = Canvas(width=800, height=600, bg= ' yellow ' ) #declare window properties
canvas.pack(expand=YES, fill= BOTH)
k = 1
j = 1
for i in range(0, 26):
canvas.create_oval(310 - k, 250 - k, 310 + k, 250 + k, width=1)#画圆
k += j
j += 1
mainloop() #Execute the entire function
Results of the:
#Line from tkinter import *
canvas =Canvas(width=300,height=300,bg= ' white ' ) #declare
window properties canvas.pack
(expand=YES,fill=BOTH) #execute window properties
x0 = 260 #declare coordinates
y0 = 260
y1 = 90
for i in range(10 ):
canvas.create_line(x0,y0,x0,y1, width =1, fill= ' red ' ) #Draw a line
x0 = x0 - 5
y0 = y0 - 5
y1 = y1 + 5
mainloop() #Execute the entire function
Results of the:
#Rectangle from tkinter import *
canvas =Canvas(width=300,height=300,bg= ' white ' ) #declare
window properties canvas.pack
(expand=YES,fill=BOTH) #execute window properties
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
mainloop ()
Results of the: