37,742
社区成员
发帖
与我相关
我的任务
分享就想这样,我想要让“你好”,这两个字的中心点在label的中心,从而实现“你好”这两个字在窗口中心,但现在中心点在左上角,导致label跑到了右下角,不知道该怎么让这个控件的中心点居中,要用place布局,谢谢了

from tkinter import *
from tkinter import ttk
welcome = Tk()
welcome.title('欢迎')
width = welcome.winfo_screenwidth()/2
height = welcome.winfo_screenheight()/2
welcome.geometry("%dx%d" % (width, height))
title = Label(text='你好', font=('微软雅黑', 72), anchor='center')
title.place(relx=0.5, rely=0.5)
welcome.mainloop()