1.Python GUI之tkinter介绍

from tkinter import Tk

#1.显示窗口
my_window=Tk()

#标题
my_window.title("我的窗口")

#设置窗口居中
#获取整个屏幕大小
screen_width, screen_height = my_window.maxsize()

#设置窗口大小
width=240
height=480
# align_str="%dx%d" % (width, height)
align_str="%dx%d+%d+%d" % (width, height,(screen_width-width)/2,(screen_height-height)/2)

#设置窗口的宽、高
my_window.geometry(align_str)

#设置窗口是否可以缩放 True表示可缩放 False表示不可缩放
my_window.resizable(width=True, height=False)

my_window.mainloop()
posted @ 2020-07-08 10:54  hank-li  阅读(447)  评论(0编辑  收藏  举报