Skip to main content

Flat dark theme for PySide, PyQt.

Project description

PyQtDarkTheme

Project status

PyPI Latest Release Python Versions Qt Versions License Code style: black

Tests

tests codeql Total alerts Language grade: Python CodeFactor pre-commit.ci status codecov

Dark and Light theme for PySide and PyQt.

PyQtDarkTheme applies a flat dark theme to PySide and PyQt. There's a light theme too. Color and style balanced from a dark theme for easy viewing in daylight.

Features:

  • A modern Dark and Light theme
  • Support PySide and PyQt(Qt5, Qt6)
  • Support some freezing library(PyInstaller, cx_freeze, py2app and etc...)
  • Resolve the differences of style between Qt versions.
  • QPalette of dark and light theme

Dark Theme

widget_gallery_dark_theme

Light Theme

widget_gallery_light_them

Requirements

Installation Method

  • Last released version
    pip install pyqtdarktheme
    
  • Latest development version
    pip install git+https://github.com/5yutan5/PyQtDarkTheme
    

Usage

import sys

from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton

import qdarktheme

app = QApplication(sys.argv)
main_win = QMainWindow()
push_button = QPushButton("PyQtDarkTheme!!")
main_win.setCentralWidget(push_button)

# Default is dark theme
app.setStyleSheet(qdarktheme.load_stylesheet())
# qdarktheme.load_stylesheet("dark")

main_win.show()

app.exec()

⚠ The image quality may be lower on Qt5(PyQt5, PySide2) due to the use of svg. You can add the following attribute to improve the quality of images.

app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)

Light theme

app.setStyleSheet(qdarktheme.load_stylesheet("light"))

QPalette of dark and light theme

You can get color of dark and light theme by loading QPalette. To load palette, run:

palette = qdarktheme.load_palette()
# qdarktheme.load_palette("dark")
# qdarktheme.load_palette("light")

For example, you can apply a link color to your application.

import sys

from PyQt6.QtGui import QPalette
from PyQt6.QtWidgets import QApplication

import qdarktheme

app = QApplication(sys.argv)
dark_palette = qdarktheme.load_palette()
palette = app.palette()
palette.setColor(QPalette.ColorRole.Link, dark_palette.link().color())
app.setPalette(palette)

Example program

To check example program, run:

python -m qdarktheme.widget_gallery

License

The svg file for the PyQtDarkTheme are derived Material design icons(Apache License Version 2.0). Qt stylesheets are originally fork of QDarkStyleSheet(MIT License). Other files are covered by PyQtDarkTheme's MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyQtDarkTheme-0.1.7.tar.gz (54.7 kB view hashes)

Uploaded Source

Built Distribution

PyQtDarkTheme-0.1.7-py3-none-any.whl (99.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page