import tkinter as tk
root = tk.Tk()
buttonOK = tk.Button(root, text='B1')
MCC = tk.Button(root, text='B2')
TID = tk.Button(root, text='B3')
CURRENCY = tk.Button(root, text='B4')
COUNTRY = tk.Button(root, text='B5')
RESPONSE = tk.Button(root, text='B6')
B1.grid(row=3, column=0, sticky=tk.E+tk.W)
B2.grid(row=3, column=1, sticky=tk.E+tk.W)
B3.grid(row=3, column=2, sticky=tk.E+tk.W)
B4.grid(row=4, column=0, sticky=tk.E+tk.W)
B5.grid(row=4, column=1, sticky=tk.E+tk.W)
B6.grid(row=4, column=2, sticky=tk.E+tk.W)
label1 = tk.Entry(root, bd =8)
label1.grid(row=2, column=0, rowspan=1, columnspan=3, sticky=tk.E+tk.W)
label=tk.Text(root,background="yellow")
label.insert(index=0.0, chars="Enter values below\nand click search.\n")
label.grid(row=0, column=0,rowspan=1, columnspan=3, sticky=tk.E+tk.W)
root.mainloop()
我想建立使用Tkinter的,但爲「請在下面輸入\ n然後點擊搜索值。\ n」個佔地約6張空白行插入的文本標籤的空間在Python的GUI。請幫我刪除它。我目前的結果使用上面的代碼是左邊的,我想要有正確的一個圖像。Tkinter的Python的消除垂直空間
您不必使用'粘= tk.E + tk.W',你可以使用'粘= 「EW」'。 –
順便說一句,你正試圖設置'B1'-'B6'到一個網格,但你還沒有定義這些名稱的任何小部件。我假設你正在嘗試將網格管理器應用到先前在代碼中列出的按鈕。如果是這樣,你需要糾正你的網格分配。 –