From e6b23664d0c7cd05d6c4f6d3cdf597b7acebeafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Sat, 4 Mar 2023 08:09:49 -0300 Subject: [PATCH] =?UTF-8?q?Calculadora:=20emitindo=20os=20n=C3=BAmeros=20e?= =?UTF-8?q?=20ponto=20digitados=20no=20display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula202-calculadora/buttons.py | 9 +++++++-- aula202-calculadora/display.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/aula202-calculadora/buttons.py b/aula202-calculadora/buttons.py index c626c77..3fc6e57 100644 --- a/aula202-calculadora/buttons.py +++ b/aula202-calculadora/buttons.py @@ -59,13 +59,18 @@ class ButtonsGrid(QGridLayout): self._equation = value self.info.setText(value) - def vouApagarVocê(self): - print('Signal recebido por "vouApagarVocê" em', type(self).__name__) + def vouApagarVocê(self, *args): + print( + 'Signal recebido por "vouApagarVocê" em', + type(self).__name__, + args, + ) def _makeGrid(self): self.display.eqPressed.connect(self.vouApagarVocê) self.display.delPressed.connect(self.display.backspace) self.display.clearPressed.connect(self.vouApagarVocê) + self.display.inputPressed.connect(self.vouApagarVocê) for rowNumber, rowData in enumerate(self._gridMask): for colNumber, buttonText in enumerate(rowData): diff --git a/aula202-calculadora/display.py b/aula202-calculadora/display.py index a11335b..e0a0b33 100644 --- a/aula202-calculadora/display.py +++ b/aula202-calculadora/display.py @@ -1,7 +1,7 @@ from PySide6.QtCore import Qt, Signal from PySide6.QtGui import QKeyEvent from PySide6.QtWidgets import QLineEdit -from utils import isEmpty +from utils import isEmpty, isNumOrDot from variables import BIG_FONT_SIZE, MINIMUM_WIDTH, TEXT_MARGIN @@ -9,6 +9,7 @@ class Display(QLineEdit): eqPressed = Signal() delPressed = Signal() clearPressed = Signal() + inputPressed = Signal(str) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -51,4 +52,9 @@ class Display(QLineEdit): if isEmpty(text): return event.ignore() - print('Texto', text) + if isNumOrDot(text): + print( + 'inputPressed pressionado, sinal emitido', type(self).__name__ + ) + self.inputPressed.emit(text) + return event.ignore()