0
我試圖將我的python數字鍵盤上的「這應該在中心」標籤中,我用tkinter和網格進行了編輯。如何使用網格將tkinter colspan中的標籤居中?
目前,它看起來像這樣: The label is not in center
我試圖添加anchor=CENTER
到標籤的屬性,但它並沒有改變。
下面是數字小的相關代碼:
class App:
numdigs = 0
def __init__(self, root):
frame = Frame(root)
grid=Frame(frame)
b = Label(root, text="This should be in center")
b.grid(row=0, column=1, columnspan=2)
b = Button(root, text="1", width=10, command= lambda *args: self.setVar(1))
b.grid(row=1, column=0)
b = Button(root, text="2", width=10,command= lambda *args: self.setVar(2))
b.grid(row=1, column=1,)
b = Button(root, text="3", width=10,command= lambda *args: self.setVar(3))
b.grid(row=1, column=2,)
b = Button(root, text="4", width=10,command= lambda *args: self.setVar(4))
b.grid(row=2, column=0,)
b = Button(root, text="5", width=10,command= lambda *args: self.setVar(5))
b.grid(row=2, column=1,)
b = Button(root, text="6", width=10,command= lambda *args: self.setVar(6))
b.grid(row=2, column=2,)
b = Button(root, text="7", width=10,command= lambda *args: self.setVar(7))
b.grid(row=3, column=0,)
b = Button(root, text="8", width=10,command= lambda *args: self.setVar(8))
b.grid(row=3, column=1,)
b = Button(root, text="9", width=10,command= lambda *args: self.setVar(9))
b.grid(row=3, column=2,)
b = Button(root, text="*", width=10,command= lambda *args: self.setVar("*"))
b.grid(row=4, column=0,)
b = Button(root, text="0", width=10,command= lambda *args: self.setVar(0))
b.grid(row=4, column=1,)
b = Button(root, text="#", width=10,command= lambda *args: self.setVar("#"))
b.grid(row=4, column=2,)
你能幫我重回正軌嗎?
中課程。謝謝! – randomcoding