0
我对Tkinter很新,但我一直在练习它,但是每当我尝试通过指定行和列来移动具有网格几何体的框架中的标签时,标签停留在中间。标签小部件不会在tkinter中的框架内移动
在下面的代码中,我尝试指定位于顶部中间框架中的名称标签的行和列,但它从不移动。它只停留在中间。
from tkinter import*
root=Tk()
frame_topleft = Frame(root, height=150, width=50, bg = "green")
frame_topmiddle = Frame(root, height=150, width=250, bg="red")
frame_topright = Frame(root, height=150, width=250, bg="green")
frame_bottomleft = Frame(root, height=300, width=50, bg="blue")
frame_bottommiddle = Frame(root, height=300, width=250, bg="yellow")
frame_bottomright = Frame(root, height=300, width=250, bg="blue")
label_name=Label(frame_topmiddle, text="Name", font="halvetica")
label_phone=Label(frame_topmiddle, text="Phone", font="halvetica")
frame_topmiddle.grid(row=0, column=1)
frame_topleft.grid(row=0, column=0)
frame_topright.grid(row=0, column=2)
frame_bottomleft.grid(row=1, column=0)
frame_bottommiddle.grid(row=1, column=1)
frame_bottomright.grid(row=1, column=2)
label_name.grid(row=0, column=0)
root.mainloop()
所以,我只是想知道如何解决这个问题。我想要顶部中间框左上方的名称标签。
谢谢!有效。 –