这是我的代码的一部分,我正在尝试调整第22列的大小。因为当没有文本时,不会出现空白空间。
我试图使用选项columnconfigure,grid_fogert,grid_remove,如你所见,但必须做错了,因为它们不起作用。
任何帮助?
from tkinter import *
janela = Tk()
janela.geometry("1300x775")
CoeSegur = Entry(janela, width=10, font=("Calibri", "12"))
CoeSegur.insert(END, 2)
CoeSegur.grid(row=10, column=3, columnspan=2, sticky=W + E)
CoeTracao = Entry(janela, width=10, font=("Calibri", "12"))
CoeTracao.insert(END, 0)
CoeTracao.grid(row=11, column=3, columnspan=2, sticky=W + E)
def btcal_click():
cleartext = (Label(janela, width=0, text=()))
cleartext.grid(row=1, rowspan=33, column=13, columnspan=23, sticky=N + S + W + E)
janela.columnconfigure(0, weight=0)
Grid.columnconfigure(janela, 0, weight=0)
test = (Label(janela, width=0))
test.grid(row=3, column=22)
test.grid_forget()
test.grid_remove()
cSeg = float(CoeSegur.get())
cSegT = float(CoeTracao.get())
if cSeg > 0 and cSegT > 0:
rta = (Label(janela, text="C. (ton.)", relief=GROOVE, font=("Calibri", "12"), width=9)).grid(row=3, column=21)
rtta = (Label(janela, text="T. (ton.)", relief=GROOVE, font=("Calibri", "12"), width=9)).grid(row=3, column=22)
else:
if cSeg == 0:
rtta = (Label(janela, text="T. (ton.)", relief=GROOVE, font=("Calibri", "12"), width=9)).grid(row=3, column=21)
else:
rta = (Label(janela, text="C. (ton.)", relief=GROOVE, font=("Calibri", "12"), width=9)).grid(row=3, column=21)
if cSeg > 0 and cSegT > 0:
rta = (Label(janela, text="C. (ton.)", bg="lightgrey", relief=GROOVE, font=("Calibri", "12"),
width=9)).grid(row=3, column=24)
rtta = (Label(janela, text="T. (ton.)", bg="lightgrey", relief=GROOVE, font=("Calibri", "12"),
width=9)).grid(row=3, column=25)
else:
if cSeg == 0:
rtta = (
Label(janela, text="T. (ton.)", bg="lightgrey", relief=GROOVE, font=("Calibri", "12"),
width=9)).grid(row=3, column=24)
else:
rta = (
Label(janela, text="C. (ton.)", bg="lightgrey", relief=GROOVE, font=("Calibri", "12"),
width=9)).grid(row=3, column=24)
btcal = (Button(janela, width=10, height=1, text="CALCULAR", font=("Calibri", "11"), bg="lightgrey", command=btcal_click)).grid(row=20, column=2, columnspan=3, sticky=W + E, padx=5)
janela.mainloop()