How to make a Tkinter window jump to the front? How to make a Tkinter window jump to the front? tkinter tkinter

How to make a Tkinter window jump to the front?


Assuming you mean your application windows when you say "my other windows", you can use the lift() method on a Toplevel or Tk:

root.lift()

If you want the window to stay above all other windows, use:

root.attributes("-topmost", True)

Where root is your Toplevel or Tk. Don't forget the - infront of "topmost"!

To make it temporary, disable topmost right after:

def raise_above_all(window):    window.attributes('-topmost', 1)    window.attributes('-topmost', 0)

Just pass in the window you want to raise as a argument, and this should work.


Add the following lines before the mainloop():

root.lift()root.attributes('-topmost',True)root.after_idle(root.attributes,'-topmost',False)

It works perfectly for me. It makes the window come to the front when the window is generated, and it won't keep it always be in the front.


If you're doing this on a Mac, use AppleEvents to give focus to Python. Eg:

import osos.system('''/usr/bin/osascript -e 'tell app "Finder" to set frontmost of process "Python" to true' ''')