Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 582
Dennis Avatar asked Jan 01 '12 03:01

Dennis


People also ask

How do I make tkinter pop up?

Popup window in Tkinter can be created by defining the Toplevel(win) window. A Toplevel window manages to create a child window along with the parent window. It always opens above all the other windows defined in any application.

Can you have multiple windows in tkinter?

Unlike the main window, you can create as many top-level windows as you want. The moment you create the Toplevel window, it'll display on the screen. Second, add widgets to the Toplevel window like you do with the frames and main window.

How do I open tkinter in the middle of the screen?

In order to place a tkinter window at the center of the screen, we can use the PlaceWindow method in which we can pass the toplevel window as an argument and add it into the center. We can also set the window to its center programmatically by defining its geometry.

How do I make a second window in tkinter?

In tkinter, we can create a Popup window or a child window by defining a Toplevel(master) constructor. This will allow the tkinter application to create another window which can be resized dynamically by defining its size property.


1 Answers

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() 
like image 143
Jake Avatar answered Sep 28 '22 21:09

Jake