Is there any way to always keep a widget on top of the others in tkinter?
Here's the code:
from tkinter import *
root = Tk()
button_1 = Button(root , text = "Button 1")
button_1.grid(row = 0 , column = 0)
button_2 = Button(root , text = "Button 2")
button_2.grid(row = 0 , column = 0)
mainloop()
Here, I positioned button_1
and button_2
in the same row, but the problem is that, as I defined button_2
after defining button_1
, button_2
stays on top of button_1
.
What I want is that button_1
should always be on top of the other widgets in the window.
Is there any way to achieve this in tkinter?
It would be great if anyone could help me out.
Use the .lift()
from tkinter import *
root = Tk()
button_1 = Button(root , text = "Button 1")
button_1.grid(row = 0 , column = 0)
button_2 = Button(root , text = "Button 2")
button_2.grid(row = 0 , column = 0)
button_1.lift()
mainloop()