Calculadora: iniciando a configuração dos botões especiais
This commit is contained in:
@@ -56,15 +56,22 @@ class ButtonsGrid(QGridLayout):
|
|||||||
|
|
||||||
if not isNumOrDot(buttonText) and not isEmpty(buttonText):
|
if not isNumOrDot(buttonText) and not isEmpty(buttonText):
|
||||||
button.setProperty('cssClass', 'specialButton')
|
button.setProperty('cssClass', 'specialButton')
|
||||||
|
self._configSpecialButton(button)
|
||||||
|
|
||||||
self.addWidget(button, rowNumber, colNumber)
|
self.addWidget(button, rowNumber, colNumber)
|
||||||
buttonSlot = self._makeButtonDisplaySlot(
|
slot = self._makeSlot(self._insertButtonTextToDisplay, button)
|
||||||
self._insertButtonTextToDisplay,
|
self._connectButtonClicked(button, slot)
|
||||||
button,
|
|
||||||
)
|
|
||||||
button.clicked.connect(buttonSlot) # type: ignore
|
|
||||||
|
|
||||||
def _makeButtonDisplaySlot(self, func, *args, **kwargs):
|
def _connectButtonClicked(self, button, slot):
|
||||||
|
button.clicked.connect(slot) # type: ignore
|
||||||
|
|
||||||
|
def _configSpecialButton(self, button):
|
||||||
|
text = button.text()
|
||||||
|
|
||||||
|
if text == 'C':
|
||||||
|
self._connectButtonClicked(button, self._clear)
|
||||||
|
|
||||||
|
def _makeSlot(self, func, *args, **kwargs):
|
||||||
@Slot(bool)
|
@Slot(bool)
|
||||||
def realSlot(_):
|
def realSlot(_):
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
@@ -78,3 +85,7 @@ class ButtonsGrid(QGridLayout):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.display.insert(buttonText)
|
self.display.insert(buttonText)
|
||||||
|
|
||||||
|
def _clear(self):
|
||||||
|
print('Vou fazer outra coisa aqui')
|
||||||
|
self.display.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user