python tkinter 窗口居中对齐,pythontkinter,tkinter没有现成的
python tkinter 窗口居中对齐,pythontkinter,tkinter没有现成的
tkinter没有现成的窗口居中的功能,只能间接地算出来。
from Tkinter import *def center_window(w=300, h=200): # get screen width and height ws = root.winfo_screenwidth() hs = root.winfo_screenheight() # calculate position x, y x = (ws/2) - (w/2) y = (hs/2) - (h/2) root.geometry('%dx%d+%d+%d' % (w, h, x, y))root = Tk()center_window(500, 300)root.mainloop()
相关内容
- Python Hello world,pythonhelloworld,#!/usr/bin/p
- python 连接 sqlalchemy orm库查询示例,sqlalchemyorm,python 连接
- Python计算24点代码,python计算24点,下面的代码通过算2
- 使用Python做数值运算,python数值运算,#!/usr/bin/p
- Python 使用字符串,python使用字符串,如下代码演示Pyth
- python String (二),pythonstring,#!/usr/bin/p
- 用Python读写XML文件,Python读写XML文件,以前用Python中的
- python String (三) 字符串运算,pythonstring,#!/usr/bin/p
- python使用py2exe打包PyQt程序要点,py2exepyqt,使用png格式作
- python使用HTMLParser解析html,pythonhtmlparser,一个Python HTM
评论关闭