diff --git a/aula202-calculadora/display.py b/aula202-calculadora/display.py new file mode 100644 index 0000000..94032b7 --- /dev/null +++ b/aula202-calculadora/display.py @@ -0,0 +1,17 @@ +from PySide6.QtCore import Qt +from PySide6.QtWidgets import QLineEdit +from variables import BIG_FONT_SIZE, MINIMUM_WIDTH, TEXT_MARGIN + + +class Display(QLineEdit): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.configStyle() + + def configStyle(self): + margins = [TEXT_MARGIN for _ in range(4)] + self.setStyleSheet(f'font-size: {BIG_FONT_SIZE}px;') + self.setMinimumHeight(BIG_FONT_SIZE * 2) + self.setMinimumWidth(MINIMUM_WIDTH) + self.setAlignment(Qt.AlignmentFlag.AlignRight) + self.setTextMargins(*margins) diff --git a/aula202-calculadora/main.py b/aula202-calculadora/main.py index 275ee6a..7b33120 100644 --- a/aula202-calculadora/main.py +++ b/aula202-calculadora/main.py @@ -1,5 +1,6 @@ import sys +from display import Display from main_window import MainWindow from PySide6.QtGui import QIcon from PySide6.QtWidgets import QApplication @@ -15,6 +16,10 @@ if __name__ == '__main__': window.setWindowIcon(icon) app.setWindowIcon(icon) + # Display + display = Display() + window.addToVLayout(display) + # Executa tudo window.adjustFixedSize() window.show() diff --git a/aula202-calculadora/main_window.py b/aula202-calculadora/main_window.py index 4d1e6e9..9466640 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 addWidgetToVLayout(self, widget: QWidget): + def addToVLayout(self, widget: QWidget): self.vLayout.addWidget(widget) diff --git a/aula202-calculadora/variables.py b/aula202-calculadora/variables.py index 234bcb3..30e74f3 100644 --- a/aula202-calculadora/variables.py +++ b/aula202-calculadora/variables.py @@ -3,3 +3,10 @@ from pathlib import Path ROOT_DIR = Path(__file__).parent FILES_DIR = ROOT_DIR / 'files' WINDOW_ICON_PATH = FILES_DIR / 'icon.png' + +# Sizing +BIG_FONT_SIZE = 40 +MEDIUM_FONT_SIZE = 24 +SMALL_FONT_SIZE = 18 +TEXT_MARGIN = 15 +MINIMUM_WIDTH = 500