TypeError: setText(self, str): too many arguments - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: TypeError: setText(self, str): too many arguments (/thread-23614.html) |
TypeError: setText(self, str): too many arguments - CabbageMan - Jan-08-2020 My code is meant to multiply a number with pi, but when I run it I get the error: TypeError: setText(self, str): too many arguments def pi(self): if self.tall_input.text() == "" or self.tall_input.text() == 0: self.tall_input.setText(format(math.pi), '.15g') else: self.tall_input.setText(format(float(self.tall_input.text()) * math.pi), '.15g')I get the error on both the 'if' and the 'else', so I'm guessing the problem is with the format() function, but I don't what. RE: TypeError: setText(self, str): too many arguments - ichabod801 - Jan-08-2020 You need to move , '.15g' inside the call to the format function. As it is now, it's a parameter to setText, when I think you want it as a parameter to format. That is, format(math.pi, '.15g') and the same on line 5.
RE: TypeError: setText(self, str): too many arguments - CabbageMan - Jan-08-2020 Thank you for the help! RE: TypeError: setText(self, str): too many arguments - LeanbridgeTech - Jan-09-2020 setText() expects a string but you are passing it a tuple, a possible solution is: self.label_2.setText(str(circles.shape)) |