I'm doing a calculator with Python 3.8 and Visual Studio. I'm trying to print the result in the label on button click.
This is the error:
Undefined variable 'resultado' pylint(undefined-variable) [37, 32]
This is my code:
from tkinter import *
r = Tk()
r.title("CALCULADORA")
def operar(num1, num2, signo):
resultado = IntVar()
if signo == "+":
resultado = num1 + num2
elif signo == "-":
resultado = num1 - num2
elif signo == "/":
resultado = num1 / num2
elif signo == "X":
resultado = num1 * num2
return resultado
textNumUno = Entry(r, width=7)
textNumUno.grid(row=0, column=0)
textOperacion = Entry(r, width=3)
textOperacion.grid(row=0, column=1)
textNumDos = Entry(r, width=7)
textNumDos.grid(row=0, column=2)
btn = Button(r, text="=", width=2, command=operar(textNumUno.get(), textNumDos.get(), textOperacion.get()))
btn.grid(row=0, column=3)
labelResultado = Label(r, text=resultado)
labelResultado.grid(row=0, column=4)
r.mainloop()