如何指定Tkinter窗口的打开位置?

如何指定Tkinter窗口的打开位置?,第1张

如何指定Tkinter窗口的打开位置?

答案基于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


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5646887.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存