import tkinter as tk

root = tk.Tk()
# 获取当前屏幕长宽
screenwidth = root.winfo_screenwidth()
screenheight = root.winfo_screenheight()
# 设定窗口的大小(长 * 宽)
width = 240
height = 180
# 设置窗口在屏幕居中
size = "%dx%d+%d+%d" % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
root.geometry(size)
root.mainloop()

 

相关文章:

  • 2021-12-02
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2021-08-06
  • 2022-01-26
  • 2021-12-27
相关资源
相似解决方案