How to put a tkinter window on top of the others?

Dennis picture Dennis · Jan 1, 2012 · Viewed 39.3k times · Source

I'm using Python 2 with Tkinter and PyObjC, and then I'm using py2app.

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 any way to control this, make the window to be on top of other windows that were open when the application is starting?

Just to clarify, it doesn't have to be on the top for the whole time the application is running. I just need it to be on top of other windows when it starts.

Answer

Jake picture Jake · Jul 12, 2017

I know this is an old question but I found it weird that no one came up with the simple solution I had,

app = SampleApp()

app.attributes('-topmost', True)
app.update()
app.attributes('-topmost', False)

app.mainloop()