diff --git a/aula202-calculadora/buttons.py b/aula202-calculadora/buttons.py index b98d89f..070ee74 100644 --- a/aula202-calculadora/buttons.py +++ b/aula202-calculadora/buttons.py @@ -1,4 +1,4 @@ -from PySide6.QtWidgets import QPushButton +from PySide6.QtWidgets import QGridLayout, QPushButton from variables import MEDIUM_FONT_SIZE @@ -13,3 +13,16 @@ class Button(QPushButton): self.setFont(font) self.setMinimumSize(75, 75) self.setProperty('cssClass', 'specialButton') + + +class ButtonsGrid(QGridLayout): + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + + self._grid_mask = [ + ['C', '◀', '^', '/'], + ['7', '8', '9', '*'], + ['4', '5', '6', '-'], + ['1', '2', '3', '+'], + ['', '0', '.', '='], + ] diff --git a/aula202-calculadora/main.py b/aula202-calculadora/main.py index f33956a..7a52d3e 100644 --- a/aula202-calculadora/main.py +++ b/aula202-calculadora/main.py @@ -1,6 +1,6 @@ import sys -from buttons import Button +from buttons import Button, ButtonsGrid from display import Display from info import Info from main_window import MainWindow @@ -22,17 +22,15 @@ if __name__ == '__main__': # Info info = Info('2.0 ^ 10.0 = 1024') - window.addToVLayout(info) + window.addWidgetToVLayout(info) # Display display = Display() - window.addToVLayout(display) + window.addWidgetToVLayout(display) - button = Button('Texto do botão') - window.addToVLayout(button) - - button2 = Button('Texto do botão') - window.addToVLayout(button2) + # Grid + buttonsGrid = ButtonsGrid() + window.vLayout.addLayout(buttonsGrid) # Executa tudo window.adjustFixedSize() diff --git a/aula202-calculadora/main_window.py b/aula202-calculadora/main_window.py index 9466640..4d1e6e9 100644 --- a/aula202-calculadora/main_window.py +++ b/aula202-calculadora/main_window.py @@ -19,5 +19,5 @@ class MainWindow(QMainWindow): self.adjustSize() self.setFixedSize(self.width(), self.height()) - def addToVLayout(self, widget: QWidget): + def addWidgetToVLayout(self, widget: QWidget): self.vLayout.addWidget(widget)