python 2.7 - How to keep a Tkinter widget on top of the others -


i have code moves images left , right not want them appear on top of right border, draw rectangle. options in tkinter keep widget (in example rectangle) on top of other widgets (in code tile, image)? drawing rectangle , image on 1 canvas.

i can image using 2 canvas trick, there other options/settings? thanks

import tkinter tk # python2 import pil.image, pil.imagetk  win = tk.tk() #create canvas canvas = tk.canvas(win, height = 500, width = 500)  #create rectangle on right of canvas rect = canvas.create_rectangle(250, 0, 500, 250, width = 2, fill = "red")  #create image sprite = pil.image.open("sprite.png") tilepil = sprite.resize((100, 100)) tilepi = pil.imagetk.photoimage(tilepil) tile = canvas.create_image(100, 100, image = tilepi, tags = "a tag")  #place canvas canvas.grid(row = 1, column = 0, rowspan = 5)  #move tile right.  #the tile go on top of red rectangle. how keep rectangle on top of tile? canvas.coords(tile, (300, 100)) canvas.mainloop() 

enter image description here

use tag_raise() method:

canvas.tag_raise(tile) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -