How do I get a Tkinter application to jump to the front? Currently, the window appears behind all my other windows and doesn’t get focus.
Is there some method I should be calling?
Advertisement
Answer
Assuming you mean your application windows when you say “my other windows”, you can use the lift()
method on a Toplevel or Tk:
JavaScript
x
2
1
root.lift()
2
If you want the window to stay above all other windows, use:
JavaScript
1
2
1
root.attributes("-topmost", True)
2
Where root
is your Toplevel or Tk. Don’t forget the -
infront of "topmost"
!
To make it temporary, disable topmost right after:
JavaScript
1
4
1
def raise_above_all(window):
2
window.attributes('-topmost', 1)
3
window.attributes('-topmost', 0)
4
Just pass in the window you want to raise as a argument, and this should work.