tkinter窗口居中方法
生活随笔
收集整理的這篇文章主要介紹了
tkinter窗口居中方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
tkinter窗口居中
from tkinter import *class MyFrm(Frame):def __init__(self, master):self.root=masterself.screen_width = self.root.winfo_screenwidth()#獲得屏幕寬度self.screen_height = self.root.winfo_screenheight() #獲得屏幕高度#self.root.resizable(False, False)#讓高寬都固定self.root.update_idletasks()#刷新GUIself.root.withdraw() #暫時(shí)不顯示窗口來移動(dòng)位置self.root.geometry('%dx%d+%d+%d' % (self.root.winfo_width(), self.root.winfo_height() ,(self.screen_width - self.root.winfo_width()) / 2,(self.screen_height - self.root.winfo_height()) / 2)) # center window on desktopself.root.deiconify() if __name__=='__main__':root=Tk()MyFrm(root)root.mainloop()轉(zhuǎn)載于:https://www.cnblogs.com/d0main/p/7613301.html
總結(jié)
以上是生活随笔為你收集整理的tkinter窗口居中方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring MVC 错误
- 下一篇: CriminalIntent项目的开发