Calculadora: configurando o PyQt Dark Theme (qdarktheme) no PySide6

This commit is contained in:
Luiz Otávio
2023-03-01 07:44:54 -03:00
parent 1ef098a9f7
commit e7684cc5ad
3 changed files with 45 additions and 0 deletions

View File

@@ -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

View File

@@ -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
)

View File

@@ -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