Python set screen center of Tkinter window

Requirements: tkinter setting window is displayed in the middle of the screen

sw = window.winfo_screenwidth()
#得到屏幕宽度
sh = window.winfo_screenheight()

#得到屏幕高度
ww = 610
wh = 400

x = (sw-ww) / 2
y = (sh-wh) / 2
window.geometry("%dx%d+%d+%d" %(ww,wh,x,y))

 

Published 128 original articles · Like 132 · Visits 170,000+

Guess you like

Origin blog.csdn.net/yql_617540298/article/details/101427313