I am developing a program for civil engineering calculations and I have a problem in the result of a Widget Entry, that same Entry is with you in an if condition as shown in the code below, but when I try to use the value typed in that field, the result is always 0. I have tried to collect as String and convert to float, but an error appears that says it could not be converted. The error appears in function confirm1, in the if == 1 condition.
# ...
if Vrd < Vd:
bws = str("Utilize uma largura mínima de viga de %.f cm" % ((Vd / (0.2 * he * fcd)) * 100))
fcks = str("Utilize um Fck mínimo de %.f MPa" % (1.4 * Vd / (200 * bw * he)))
# Janela de verificação de cisalhamento
verificacao1 = Tk()
verificacao1.title("ERRO NA VERIFICAÇÃO")
verificacao1.geometry("+300+100")
# Frames
frame_top1 = Frame(verificacao1)
frame_top1.pack()
frame_sugestoes = Frame(verificacao1)
frame_sugestoes.pack(side=LEFT)
def bt_click_nao1():
verificacao1.destroy()
return
def bt_click_sim1():
bt_sim1["state"] = "disabled"
global raid11
raid11 = IntVar()
def ck1():
ck_Afck["state"] = "disabled"
en_fck["state"] = "disabled"
global teste
teste = 1
return
def ck2():
ck_Alargura["state"] = "disabled"
en_largura["state"] = "disabled"
global teste
teste = 2
return
def reset():
ck_Alargura["state"] = "normal"
ck_Afck["state"] = "normal"
ck_Alargura.deselect()
ck_Afck.deselect()
en_largura["state"] = "normal"
en_fck["state"] = "normal"
en_largura.delete(first=0, last=11)
en_fck.delete(first=0, last=11)
return
def confirmar1():
verificacao1.destroy()
if teste == 1:
*bw1 = raid11.get() * 0.01*
# Carregamento
Q = (bw1 * h * 25) + Gi + Gs
# print(f'#Novo Carregamento: 3[33m{Q:.2f} KN/m3[m')
# Esforços Solicitantes
V = (Q * le) / 2
M = (Q * pow(le, 2)) / 8
# print(f'#Nova Cortante: 3[33m{V:.2f} KN3[m')
# print(f'#Novo Momento Máximo: 3[33m{M:.2f} KN.m3[m')
# Verificação do Concreto
# Cisalhamento
fcd = (fck * 1000) / 1.4
Vrd = 0.20 * bw1 * he * fcd
Vd = 1.4 * V
print(f'#Nova cortante de cálculo: 3[33m{Vd:.2f} KN3[m')
print(f'#Nova resistênca de cálculo: 3[33m{Vrd:.2f} KN3[m')
if teste == 2:
# Carregamento
Q = (bw * h * 25) + Gi + Gs
# print(f'#Novo Carregamento: 3[33m{Q:.2f} KN/m3[m')
# Esforços Solicitantes
V = (Q * le) / 2
M = (Q * pow(le, 2)) / 8
# print(f'#Nova Cortante: 3[33m{V:.2f} KN3[m')
# print(f'#Novo Momento Máximo: 3[33m{M:.2f} KN.m3[m')
# Verificação do Concreto
# Cisalhamento
fcd = (fck * 1000) / 1.4
vrd = 0.20 * bw * he * fcd
Vd = 1.4 * V
# print(f'#Nova cortante de cálculo: 3[33m{Vd:.2f} KN3[m')
# print(f'#Nova resistênca de cálculo: 3[33m{Vrd:.2f} KN3[m')
# Zona de Apoio
Vd1 = Vd * 1.1
Vrd1 = 0.8 * bw * (c1 + hf) * fcd
print(f'Solicitação na zona de apoio: 3[33m{Vd1:.2f} KN3[m')
print(f'Resistência da zona de apoio: 3[33m{Vrd1:.2f} KN3[m')
return
# textos e CheckButtons de escolha
lb_escolaSolucao = Label(frame_sugestoes, text="ESCOLHA A SOLUÇÃO:", font=("Arial", 12, "bold"), pady=10,
bd=3, fg="#1E90FF", anchor="center")
lb_escolaSolucao.grid(row=0, column=3)
ck_Alargura = Checkbutton(frame_sugestoes, text="Aumentar largura", font=("Segoe UI", 12), command=ck1)
ck_Alargura.grid(row=1, column=3, sticky=W)
ck_Afck = Checkbutton(frame_sugestoes, text="Aumentar o Fck", font=("Segoe UI", 12), command=ck2)
ck_Afck.grid(row=2, column=3, sticky=W)
# Entrada de dados
en_largura = Entry(frame_sugestoes, font=("Century Gothic", 11), textvariable=raid11, bd=5, insertwidth=4,
width=12, bg="#1E90FF", justify="right")
en_largura.grid(row=1, column=4)
en_fck = Entry(frame_sugestoes, font=("Century Gothic", 11), textvariable=raid12, bd=5, insertwidth=4,
width=12, bg="#1E90FF", justify="right")
en_fck.grid(row=2, column=4)
# botões reset e confirmar
bt_reset = Button(frame_sugestoes, text="RESET", font=("Arial", 12, "bold"), bg="#1E90FF", padx=16, pady=0,
bd=2, width=7, command=reset)
bt_reset.grid(row=4, column=3, sticky=E)
bt_confirmar1 = Button(frame_sugestoes, text="CONFIRMAR", font=("Arial", 12, "bold"), bg="#1E90FF", padx=16,
pady=0, bd=2, width=7, command=confirmar1)
bt_confirmar1.grid(row=4, column=4, sticky=W)
# Textos
lb_alerta1 = Label(frame_top1, text="A ESTRUTURA NÃO SUPORTA O EFEITO DE CISALHAMENTO NO CONCRETO",
font=("Arial", 13, "bold"), pady=12, fg="#1E90FF")
lb_alerta1.grid(row=0, column=0)
lb_psugestoes = Label(frame_sugestoes, text="POSSÍVEIS SOLUÇÕES", font=("Arial", 12, "bold"), pady=10, bd=3,
fg="#1E90FF")
lb_psugestoes.grid(row=0, column=0)
lb_largura = Label(frame_sugestoes, text=bws, font=("Segoe UI", 12))
lb_largura.grid(row=1, column=0, sticky=W)
lb_fck = Label(frame_sugestoes, text=fcks, font=("Segoe UI", 12))
lb_fck.grid(row=2, column=0, sticky=W)
lb_quest1 = Label(frame_sugestoes, text="Deseja aplicar alguma solução? ", font=("Segoe UI", 12))
lb_quest1.grid(row=4, column=0, sticky=W)
lb_linha1 = Label(frame_sugestoes)
lb_linha1.grid(row=3, column=0)
# botões - SIM/NÃO
bt_sim1 = Button(frame_sugestoes, text="SIM", font=("Arial", 12, "bold"), bg="#1E90FF", padx=8, pady=0, bd=2,
width=5, command=bt_click_sim1)
bt_sim1.grid(row=4, column=0, sticky=E)
bt_nao1 = Button(frame_sugestoes, text="NÃO", font=("Arial", 12, "bold"), bg="#1E90FF", padx=8, pady=0, bd=2,
width=5, command=bt_click_nao1)
bt_nao1.grid(row=4, column=2, sticky=W)
verificacao1.mainloop()
Well, explaining more about my doubt. This program does security checks, if
at the beginning states that if the request is greater than the resistor the program must execute the whole (giant) block below. Well in this block is created a new small window that serves only to alert the user that there is an error and conveniently point a solution to the error, the user must enter a new value for the data that will correct the problem (eg. 15cm of the error, but with 18cm is enough, the user can enter the 18cm or a larger value). The problem is that I am not able to capture this new value. And in response to jsbueno, I already tried to use float
. And this * 0.01
is simply a multiplication of the captured value (user type in cm and the program does the calculations in m).