# 用line画直线。
from tkinter import *
class Line:
def __init__(self):
canvas = Canvas(width=500, height=500, bg='yellow')
canvas.pack()
x0, y0, x1, y1 = 10, 10, 500, 500
for i in range(25):
canvas.create_line(x0, y0, x0, y1, width=1, fill='red')
x0 += 10
y0 += 10
x1 -= 10
y1 -= 10
mainloop()
if __name__ == '__main__':
a_line = Line()
运行结果: