Calculadora: emitindo os números e ponto digitados no display
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user