diff --git a/aula202-calculadora/main.py b/aula202-calculadora/main.py index be1f6a8..34e95d2 100644 --- a/aula202-calculadora/main.py +++ b/aula202-calculadora/main.py @@ -5,11 +5,13 @@ from info import Info from main_window import MainWindow from PySide6.QtGui import QIcon from PySide6.QtWidgets import QApplication +from styles import setupTheme from variables import WINDOW_ICON_PATH if __name__ == '__main__': # Cria a aplicação app = QApplication(sys.argv) + setupTheme() window = MainWindow() # Define o ícone diff --git a/aula202-calculadora/styles.py b/aula202-calculadora/styles.py new file mode 100644 index 0000000..c25f2c5 --- /dev/null +++ b/aula202-calculadora/styles.py @@ -0,0 +1,38 @@ +# QSS - Estilos do QT for Python +# https://doc.qt.io/qtforpython/tutorials/basictutorial/widgetstyling.html +# Dark Theme +# https://pyqtdarktheme.readthedocs.io/en/latest/how_to_use.html +import qdarktheme +from variables import (DARKER_PRIMARY_COLOR, DARKEST_PRIMARY_COLOR, + PRIMARY_COLOR) + +qss = f""" + PushButton[cssClass="specialButton"] {{ + color: #fff; + background: {PRIMARY_COLOR}; + }} + PushButton[cssClass="specialButton"]:hover {{ + color: #fff; + background: {DARKER_PRIMARY_COLOR}; + }} + PushButton[cssClass="specialButton"]:pressed {{ + color: #fff; + background: {DARKEST_PRIMARY_COLOR}; + }} +""" + + +def setupTheme(): + qdarktheme.setup_theme( + theme='dark', + corner_shape='rounded', + custom_colors={ + "[dark]": { + "primary": f"{PRIMARY_COLOR}", + }, + "[light]": { + "primary": f"{PRIMARY_COLOR}", + }, + }, + additional_qss=qss + ) diff --git a/aula202-calculadora/variables.py b/aula202-calculadora/variables.py index 30e74f3..d9c5d62 100644 --- a/aula202-calculadora/variables.py +++ b/aula202-calculadora/variables.py @@ -4,6 +4,11 @@ ROOT_DIR = Path(__file__).parent FILES_DIR = ROOT_DIR / 'files' WINDOW_ICON_PATH = FILES_DIR / 'icon.png' +# Colors +PRIMARY_COLOR = '#1e81b0' +DARKER_PRIMARY_COLOR = '#16658a' +DARKEST_PRIMARY_COLOR = '#115270' + # Sizing BIG_FONT_SIZE = 40 MEDIUM_FONT_SIZE = 24