There is a solution for raising canvas windows over other canvas windows: How do you change the stacking order of window items in a canvas? But I am not able to raise a not-canvas-window item (for example a canvas rectangle) above a canvas window item. How can I do this?
Here is an example code where I try to raise the rectangle above a canvas window (the example was copied from the link above and extended by a canvas rectangle):
root = tk.Tk()
canvas = tk.Canvas(root, bg="bisque")
canvas.pack(fill="both", expand=True)
def focus_win(event):
event.widget.lift()
for n, color in enumerate(("black", "red", "orange", "green", "blue", "white")):
win = tk.Frame(canvas, background=color, width=100, height=100)
x = 50 + n*20
y = 50 + n*20
canvas.create_window(x, y, window=win)
win.bind("<1>", focus_win)
rec = canvas.create_rectangle(x, y, x+100, y+100)
canvas.tag_raise(rec, "all")
root.mainloop()
You can't. The documentation says:
Or can you ?
I mean you always could have multiple canvases as window-items and draw what ever you want to in those canvases.