Anchor的值在tkinter,python3.7中看起来是相反的

2024-06-01 20:18:14 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在tkinter中使用anchor in place()mythod时,按钮的位置似乎与我设置的位置相反

from tkinter import *

win = Tk()


frame = Frame(win, relief=RAISED, borderwidth=1, width=400, height=300)
frame.pack(fill=BOTH, ipadx=5, ipady=5, expand=1)

button1 = Button(frame, text="Button 1")
button1.place(x=200, y=150, anchor=NW, width=200, height=150)


win.mainloop()

如您所见,我将按钮锚定(我的意思是x=200,y=150)设置在帧的中心,锚定的值是NW。按钮应该放在框架的左上角,但它在它的右下角,它完全颠倒了。 我很困惑,我尽我所能去谷歌看看,但似乎没有人有和我一样的问题,如果有人可以帮助我吗


Tags: infromtkinterplacebuttonwidth按钮frame