a = IntVar(root, aEntry.get())
b = IntVar(root, bEntry.get())
c = IntVar(root, cEntry.get())
y = a*x**2 b*x c
This gives me this error: "TypeError: unsupported operand type(s) for *: 'IntVar' and 'float'". If it helps, I am trying to use that equation to draw a quadratic graph using numpy and matplotlib.
CodePudding user response:
You're multiplying the IntVar
object itself, which is wrong.
Instead, you want to multiply the value that is stored inside the IntVar
. Use .get()
to fetch the value.
y = a.get() * x**2 b.get() * x c.get()
CodePudding user response:
You don't need to use IntVar
at all, just convert the content from those entries to integer:
try:
a = int(aEntry.get())
b = int(bEntry.get())
c = int(cEntry.get())
y = a * x**2 b * x c
except ValueError as ex:
print(ex)