estoy realizando un programa utilizando programación en Python con la librería Tkinter. Quiero que mi interfaz gráfica vaya almacenando y calculando los valores que estoy dando, pero no encuentro la forma de hacerlo, simplemente se reemplazan los datos. ¿Existe alguna manera de volver al if o algo parecido? Muchas gracias de antemano.
from tkinter import *
from tkinter import messagebox as box
ventana = Tk()
ventana.title("Ejercicio")
ventana.geometry("750x450")
ventana.configure(background = "white")
R = DoubleVar()
conexion = DoubleVar()
cont = IntVar()
Rq = DoubleVar()
def calcular():
comercial = [100, 120, 150, 180, 220, 270, 330, 390, 470, 510, 560, 680, 820, 1000, 1200, 1500, 1800, 2200, 2700, 3300, 3900,
4700, 5100, 5600, 6800, 8200]
if R.get() not in comercial:
box.showwarning("AVISO", "La resistencia ingresada no es comercial.")
Rt = 0
i = 0
Rx = int(R.get())
if conexion.get() == 1:
Rt = Rt + Rx
i = i + 1
Rq.set(round(Rt, 4))
cont.set(i)
if conexion.get() == 2:
Rn = 1E10
Calc = 1 / (1/Rx + 1/Rn)
Rt = Rt + Calc
i = i + 1
Rq.set(round(Rt, 4))
cont.set(i)
#ENTRADAS
letrero0 = Label(ventana, text = "CÁLCULO DE RESISTENCIA EQUIVALENTE EN UN ARREGLO MIXTO", bg = "white", font = "Arial 14 bold")
letrero0.place(x = 50, y = 20, width = 650, height = 30)
letrero1 = Label(ventana, text = "Valor de resistencia", bg = "azure", font = "Arial 12 bold")
letrero1.place(x = 80, y = 80, width = 160, height = 30)
entrada1 = Entry(ventana, textvariable = R, bg = "white").place(x = 110, y = 115, width = 100, height = 30)
letrero2 = Label(ventana, text = "Tipo de conexión", bg = "azure", font = "Arial 12 bold").place(x = 80, y = 180, width = 180, height = 30)
Radiobutton(ventana, text = "Serie", bg = "white", variable = conexion, value = 1).place(x = 100, y = 220, width = 50, height = 30)
Radiobutton(ventana, text = "Paralelo", bg = "white", variable = conexion, value = 2).place(x = 100, y = 250, width = 70, height = 30)
letrero3 = Label(ventana, text = "Resistencias contadas:", bg = "azure", font = "Arial 12 bold")
letrero3.place(x = 80, y = 300, width = 180, height = 30)
#COMANDOS
boton1 = Button(ventana, text = "CALCULAR", bg = "green", command = calcular).place(x = 300, y = 250, width = 100, height = 30)
#SALIDAS
letrero4 = Label(ventana, text = "Resistencia Equivalente", bg = "azure", font = "Arial 12 bold")
letrero4.place(x = 450, y = 80, width = 200, height = 30)
salida1 = Label(ventana, textvariable = Rq, bg = "white").place(x = 460, y = 120, width = 190, height = 30)
salida2 = Label(ventana, textvariable = cont, bg = "white").place(x = 280, y =300, width = 50, height = 30)
letrero5 = Label(ventana, text = "Ω", bg = "white", font = "Arial 12").place(x = 600, y = 120, width = 20, height = 20)
letrero6 = Label(ventana, text = "Ω", bg = "white", font = "Arial 12").place(x = 330, y = 300, width = 20, height = 20)
ventana.mainloop()
calcular()
correctamente... ninguna línea está dentro de dicho método! No es posible que el código se ejecute bien si no está bien indentado para empezar.