Reputation: 1
I'm creating a calculator with PySide6
. In all methods I created, doing this buttonText = button.text()
works well, but for some reason, in this specific method, Python says that my button is a boolean and booleans don't have text
attribute:
def _operatorClicked(self, button: Button):
buttonText = button.text() # The error is happening here
displayText = self.display.text()
if not isValidNumber(displayText) and self._leftNum is None:
return
if self._leftNum is None:
self._leftNum = float(displayText)
self._operator = buttonText
self.equation = f'{self._leftNum} {self._operator} ??'
Like I said, Python is considering the button as a bool even if I type it with QPushButton
class. This only happens on this method and I dont know why.
I tried to remove the bool from the Slot decorator (@Slot(bool) -> I removed this bool) but it didn't work, and i just dont know from where is coming that bool
Upvotes: 0
Views: 36