Dennis Dennis - 3 months ago 13
Python Question

How to put a Tkinter window on top of the others

I'm using Python 2 with

, and then I'm using

The program is working fine, but the window starts as hidden whenever I open the program, so it doesn't appear until I click on the icon on the dock to bring it up.

Is there anyway to control this, make the window to be on top of other windows that were open when the application is starting?


If I take the code you give and add the first and last line you get:

from Tkinter import *

root = Tk() 
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
root.geometry("550x250+%d+%d" % (screen_width/2-275, screen_height/2-125))
root.lift ()


Test it. I get the window as expected. Do you get something else? If this works then somewhere in the code you are telling it to do that. If it does the same thing as your real program then your window manager is doing it. This is the best I can do without more information.


On osx (espicially versions using aqua) tkinter's windows may be displayed behind those that are already open (this has a bug report here: but has been closed as will not fix). The addition of the root.lift() command has been included to bring the window to the front of the stack in those cases and is harmless in all others.