[Python] Python is considering my button as a bool type

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    Im 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, the 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, the 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

    Continue reading...

Compartilhe esta Página