from tkinter import *
window = Tk()
w = Canvas(window,width=200,height=200,background="white")
w.pack()
w.create_line(0,100, 200, 100, fill='blue', dash=(4, 4))
w.create_line(100, 0, 100, 200, fill='red', dash=(4, 4))
w.create_rectangle(50, 50, 150, 150, fill='red')
b = Button(window,text='删除全部',command=(lambda x=ALL: w.delete(x)))
b.pack()
mainloop()
dash 虚线,参数:长度,间隔