canvas 上的框架与 canvas 中创建的线重叠

frame on canvas overlapping a line created in canvas

我需要在 canvas 中创建一个框架,以便删除用户可以放置在 canvas 中的相当数量的小部件。它放在框架中,所以我可以用 canvas.delete("all") 删除它们。我还需要一些线条,因为 Frame 不接受线条,我需要直接在下面的 canvas 中创建它。问题是框​​架与线重叠。我尝试了 canvas.lift() 和 tag.raise() 方法,但它们不起作用。知道如何解决吗?

from tkinter import *

root = Tk()
root.geometry('1560x750')

canvas_right=Canvas(root)
canvas_right.config(width=1000, height=1560, bg='light grey')
canvas_right.grid(row=1,column=3, rowspan=1550,ipadx=1300,ipady=750,sticky=NW)

frame = Frame(canvas_right, bg='light blue')
main_frame = canvas_right.create_window(500, 780, height=1700, width=760, window=frame)

line1 = canvas_right.create_line(100,100,3000,1000)
canvas_right.lift(line1)

root.mainloop()

放置在 canvas 中的小部件将始终位于其他图形项目(如线条和圆圈)之上。无法解决该限制。

来自canonical tcl/tk documentation

Note: due to restrictions in the ways that windows are managed, it is not possible to draw other graphical items (such as lines and images) on top of window items. A window item always obscures any graphics that overlap it, regardless of their order in the display list. Also note that window items, unlike other canvas items, are not clipped for display by their containing canvas's border, and are instead clipped by the parent widget of the window specified by the window option; when the parent widget is the canvas, this means that the window item can overlap the canvas's border.