该答案基于Rachel的答案。她的代码本来就不起作用,但是通过一些调整,我得以解决错误。
import tkinter as tkroot = tk.Tk() # create a Tk root windoww = 800 # width for the Tk rooth = 650 # height for the Tk root# get screen width and heightws = root.winfo_screenwidth() # width of the screenhs = root.winfo_screenheight() # height of the screen# calculate x and y coordinates for the Tk root windowx = (ws/2) - (w/2)y = (hs/2) - (h/2)# set the dimensions of the screen # and where it is placedroot.geometry('%dx%d+%d+%d' % (w, h, x, y))root.mainloop() # starts the mainloop
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)