2
Contributors
1
Reply
7
Views
10 Years
Discussion Span
Last Post by Ene Uran
0

Not knowing Tkinter that well, here is a somewhat simple minded approach:

from Tkinter import *

def center_window(w=300, h=200):
    # get screen width and height
    ws = root.winfo_screenwidth()
    hs = root.winfo_screenheight()
    # calculate position x, y
    x = (ws/2) - (w/2)    
    y = (hs/2) - (h/2)
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))

root = Tk() 
center_window(500, 300) 
root.mainloop()

Edited by vegaseat: changed code frame

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.