Skip to content Skip to sidebar Skip to footer

Python Gui Typeerror: 'str' Object Is Not Callable

Ok so I'm supposed to make a basic calculator using GUI in python. I completed that task with all buttons working. Now for step 2, I'm supposed to inherit the original calculator

Solution 1:

Without looking at the rest of the code, I see an obvious typo / brain-o in pow:

defpow(self):
    self.opt = 'pow'
    self.op1 = float(self.n.get())
    self.n.set = ('')

That last line should be:

    self.n.set('')

without the = part, so as to call self.n.set, not to replace the function with a string. (Replacing the function with a string will cause a later attempt to call self.n.set to produce the error you saw.)

Solution 2:

Look at your pow() method

self.n.set = ('')

It's definitely is a typo. Replace with

self.n.set('')

Post a Comment for "Python Gui Typeerror: 'str' Object Is Not Callable"