首页 > 解决方案 > 无论屏幕大小如何,如何将小部件放在窗口的某个位置。特金特

问题描述

我将 tkinter 窗口设置为全屏,但是当我使用 place 时,它​​不会将小部件放在屏幕上。在较小屏幕上的中心不是我屏幕的中心。

有谁知道有什么办法让它保持为中心。

Python3顺便说一句。

def Quit():
    os._exit(1)

window1=tkinter.Tk()
window1.title("QUEST")
#window1.geometry("500x500")
window1.configure(bg="black")
window1.attributes("-fullscreen", True)

menubar = tkinter.Menu(window1)
filemenu = tkinter.Menu(menubar, tearoff=0)
menubar.add_cascade(label="Quit", command=Quit)

window1.config(menu=menubar)

Label=tkinter.Label(window1, text="WELCOME TO", bg="black", fg="white", font=("century gothic",50))
Label.place(x=725, y=60)
Label2=tkinter.Label(window1, text="QUEST", bg="black", fg="white", font=("century gothic",50))
Label2.place(x=850, y=160)
bt=tkinter.Button(window1, bg="lightgray", fg="black", text="START", font=("century gothic",30), command=Start)
bt.place(x=250, y=600)
bt2=tkinter.Button(window1, bg="lightgray", fg="black", text="QUIT", font=("century gothic",30), command=Quit)
bt2.place(x=1500, y=600)

window1.mainloop()

标签: pythontkinter

解决方案


推荐阅读