[Tutor] Is there an easy way to center the root window (Tkinter) within the display?

Alan Gauld alan.gauld at btinternet.com
Wed Nov 26 18:23:17 CET 2014

On 26/11/14 16:46, boB Stepp wrote:

> I can accomplish this by getting the screen height and width and
> calculating pixel coordinates. But so far I have not found something
> equivalent to anchor = 'CENTER' that can be applied to the root
> window. Does such an easy attribute, method, or whatever exist in
> Tkinter?

I'm not aware of one.
But forcing a window to be centre of the display is usually
a bad idea - and very annoyying to the user, especially if they have 
explicitly set their preferences for where new windows should appear.

More useful is to put it centre of the applications top level window
since thats where the users attention should be fixed! Most important of 
all is to ensure it goes on top (assuming its something important that 
you are splatting in front of them and not just some dull
report message like "File saved...").

But generally I leave such matters to the users preferences and
the OS. They know much more than I do about how the user wants
to work and what else is going on with the machine at the time.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list