from tkinter import *
Window = Tk()
Window.attributes('-fullscreen', True)
b1 = Button(Window, text="1", activeforeground="black", activebackground="gray", pady=2,
font='secular_one', relief=GROOVE)
b1.place(x=1100, y=50)
b2 = Button(Window, text="2", activeforeground="black", activebackground="gray", pady=2,
font='secular_one', relief=GROOVE)
b2.place(x=1100, y=220)
b3 = Button(Window, text="3", activeforeground="black", activebackground="gray", pady=2,
font='secular_one', relief=GROOVE)
b3.place(x=1100, y=380)
Window.mainloop()
我正在制作一個使用 Tkinter 的應用程式,我想將一些按鈕放在某個位置,所以在我使用 .place 完成該操作后,我去另一臺計算機上作業,但按鈕位于螢屏中間而不是我放置的位置他們原本
uj5u.com熱心網友回復:
kwargsx和yfor以像素place為單位定義小部件的絕對位置。因此,如果您在不同解析度的顯示幕上運行該程式,它看起來就不一樣了。
嘗試定義相對位置:
b1.place(relx=0.3, rely=0.1)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/536903.html
下一篇:pythontkinter主視窗
