Calculadora: configurando o PyQt Dark Theme (qdarktheme) no PySide6
This commit is contained in:
@@ -5,11 +5,13 @@ from info import Info
|
|||||||
from main_window import MainWindow
|
from main_window import MainWindow
|
||||||
from PySide6.QtGui import QIcon
|
from PySide6.QtGui import QIcon
|
||||||
from PySide6.QtWidgets import QApplication
|
from PySide6.QtWidgets import QApplication
|
||||||
|
from styles import setupTheme
|
||||||
from variables import WINDOW_ICON_PATH
|
from variables import WINDOW_ICON_PATH
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# Cria a aplicação
|
# Cria a aplicação
|
||||||
app = QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
|
setupTheme()
|
||||||
window = MainWindow()
|
window = MainWindow()
|
||||||
|
|
||||||
# Define o ícone
|
# Define o ícone
|
||||||
|
|||||||
38
aula202-calculadora/styles.py
Normal file
38
aula202-calculadora/styles.py
Normal 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
|
||||||
|
)
|
||||||
@@ -4,6 +4,11 @@ ROOT_DIR = Path(__file__).parent
|
|||||||
FILES_DIR = ROOT_DIR / 'files'
|
FILES_DIR = ROOT_DIR / 'files'
|
||||||
WINDOW_ICON_PATH = FILES_DIR / 'icon.png'
|
WINDOW_ICON_PATH = FILES_DIR / 'icon.png'
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
PRIMARY_COLOR = '#1e81b0'
|
||||||
|
DARKER_PRIMARY_COLOR = '#16658a'
|
||||||
|
DARKEST_PRIMARY_COLOR = '#115270'
|
||||||
|
|
||||||
# Sizing
|
# Sizing
|
||||||
BIG_FONT_SIZE = 40
|
BIG_FONT_SIZE = 40
|
||||||
MEDIUM_FONT_SIZE = 24
|
MEDIUM_FONT_SIZE = 24
|
||||||
|
|||||||
Reference in New Issue
Block a user