### Install QDarkStyleSheet from source using setup.py
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Install qdarkstyle from its source code using the setup script and pip.
```bash
pip install .
```
--------------------------------
### Install QDarkStyleSheet from source using Python
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Install qdarkstyle from its source code using the setup script directly with Python.
```bash
python setup.py install
```
--------------------------------
### Run graphical examples
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Launches the example application to verify theme changes.
```bash
python qdarkstyle\example
```
--------------------------------
### Run QDarkStyleSheet Example Application
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
Command-line examples to run the included QDarkStyleSheet example application with different palette options.
```bash
# dark theme example
$ qdarkstyle.example --palette=dark
```
```bash
# light theme example
$ qdarkstyle.example --palette=light
```
```bash
# no theme/style sheet applied
$ qdarkstyle.example --palette=none
```
```bash
# check all options included
$ qdarkstyle.example --help
```
--------------------------------
### Setup Virtual Environment with virtualenv
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Create and activate a virtual environment using virtualenv, then install the project with development dependencies.
```bash
virtualenv ~/.venv
. ~/.venv/bin/activate
pip install -e .[develop]
```
--------------------------------
### Setup Development Environment with Conda
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Create and activate a conda environment, install necessary packages, and then install the project with development dependencies.
```bash
conda create -n my-dev-env -c conda-forge python=3.8
conda activate my-dev-env
conda remove --force qdarkstyle # In case you have qdarkstyle installed
conda install -c conda-forge watchdog qtsass
pip install -e .[develop]
```
--------------------------------
### Run qdarkstyle example with command line arguments
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.example.__main__.md
Execute the example script using different Qt bindings and palette configurations via command line flags.
```bash
python example.py
```
```bash
python example.py --qt_from=pyqt5
```
```bash
python example.py --qt_from=pyqt5 --palette=none
```
--------------------------------
### Run QDarkStyleSheet Examples via CLI
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Command line interface commands to launch the included example application with different themes.
```bash
# dark theme example
$ qdarkstyle.example --palette=dark
# light theme example
$ qdarkstyle.example --palette=light
# no theme/style sheet applied
$ qdarkstyle.example --palette=none
# check all options included
$ qdarkstyle.example --help
```
--------------------------------
### Install from test PyPI
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Installs the package from the test repository for verification.
```bash
pip install --no-deps --index-url https://test.pypi.org/simple/ qdarkstyle
```
--------------------------------
### Install twine
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Installs the twine utility for package distribution.
```bash
pip install twine
```
--------------------------------
### Import qdarkstyle Module
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Start by importing the qdarkstyle module to access its functionalities.
```python
import qdarkstyle
```
--------------------------------
### Setup Development Environment
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/contributing.md
Commands to configure a virtual environment for development using virtualenv or conda.
```bash
virtualenv ~/.venv
. ~/.venv/bin/activate
pip install -e .[develop]
```
```bash
conda create -n my-dev-env -c conda-forge python=3.8
conda activate my-dev-env
conda remove --force qdarkstyle # In case you have qdarkstyle installed
conda install -c conda-forge watchdog qtsass
pip install -e .[develop]
```
--------------------------------
### Install QDarkStyleSheet via pip
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Use pip to install the latest stable version of the qdarkstyle package.
```bash
pip install qdarkstyle
```
--------------------------------
### Initialize QDarkStyleSheet with Default Settings
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Basic setup for applying the stylesheet using the default Qt environment variable.
```python
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
# the default system in qdarkstyle uses qtpy environment variable
app.setStyleSheet(qdarkstyle.load_stylesheet())
# run
window.show()
app.exec_()
```
--------------------------------
### QDarkStyle Command Line Interface
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Provides utilities for checking version, system information, and running example applications with specific themes.
```bash
# Show QDarkStyle version
python -m qdarkstyle --version
# Output: v3.2.3
# Show help
python -m qdarkstyle --help
# Show system information (requires helpdev package)
python -m qdarkstyle --information
# Show available Qt bindings
python -m qdarkstyle --bindings
# Show available abstraction layers
python -m qdarkstyle --abstractions
# Show all information at once
python -m qdarkstyle --all
# Run example application with dark theme
python -m qdarkstyle.example --palette=dark
# Run example application with light theme
python -m qdarkstyle.example --palette=light
# Run example without any theme (native OS look)
python -m qdarkstyle.example --palette=none
# Specify Qt binding for example
python -m qdarkstyle.example --qt_from=pyqt6 --palette=dark
# Run example in test mode (auto-closes after 2 seconds)
python -m qdarkstyle.example --palette=dark --test
# Generate screenshots
python -m qdarkstyle.example --palette=dark --screenshots
```
--------------------------------
### Application Execution and Automation
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.example.__main__.md
Functions for executing the example application and automating screenshot generation.
```APIDOC
## create_screenshots(app, window, args)
### Description
Saves screenshots for different application views and terminates the application.
### Parameters
- **app** (object) - The QApplication instance.
- **window** (object) - The main window instance.
- **args** (object) - Command line arguments.
## main()
### Description
Main entry point to execute the QDarkStyle example application.
```
--------------------------------
### Checkout Develop Branch
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Switch to the 'develop' branch to start making changes.
```bash
git checkout develop
```
--------------------------------
### Icon Examples Table Header
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/contributing.md
HTML table header definition for the icon examples section.
```default
Examples of icons |
```
--------------------------------
### Load Stylesheet for PyQtGraph with PyQt5
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
This example shows how to set the environment variable for PyQtGraph to use PyQt5 and then load the stylesheet. Note that PyQtGraph typically uses the PyQt4 API.
```python
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to PyQt, PyQt5, PySide or PySide2 (not implemented yet)
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
# import from pyqtgraph instead of doing it directly
# note that PyQtGraph always uses PyQt4 API
from pyqtgraph.Qt import QtGui
# create the application and the main window
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB']))
# run
window.show()
app.exec_()
```
--------------------------------
### Set Qt API environment variable and import from QtPy
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Set the QT_API environment variable to specify the Qt wrapper and then import modules from QtPy. This example uses PyQt5.
```python
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to pyqt, pyqt5, pyside or pyside2 (not implemented yet)
# you do not need to use QtPy to set this variable
os.environ['QT_API'] = 'pyqt5'
# import from QtPy instead of doing it directly
# note that QtPy always uses PyQt5 API
from qtpy import QtWidgets
```
--------------------------------
### Icon Examples Table Data
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/contributing.md
HTML table data containing image references for specific icons.
```default
 |
 |
 |
```
--------------------------------
### Uninstall package
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Removes the installed package.
```bash
pip uninstall qdarkstyle -y
```
--------------------------------
### Clone and Checkout Repository
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/contributing.md
Initial steps to clone the forked repository and switch to the development branch.
```bash
git clone https://github.com/USERNAME/qdarkstyle
cd qdarkstyle
```
```bash
git checkout develop
```
--------------------------------
### Load QDarkStyleSheet directly with PyQt5 in Python
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
Create a PyQt5 application and load the QDarkStyleSheet directly.
```python
import sys
import qdarkstyle
from PyQt5 import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
```
--------------------------------
### Apply Stylesheet to QApplication
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Set the loaded dark stylesheet to your QApplication instance.
```python
app.setStyleSheet(dark_stylesheet)
```
--------------------------------
### Initialize PlotWidget with QDarkStyle
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Demonstrates setting a PlotWidget background to transparent to inherit the stylesheet background.
```python
plot_widget = pg.PlotWidget()
plot_widget.setBackground(None) # Use stylesheet background
plot_widget.plot([1, 2, 3, 4, 5], [1, 4, 9, 16, 25], pen='w')
window.setCentralWidget(plot_widget)
window.resize(800, 600)
window.show()
app.exec_()
```
--------------------------------
### Get Ordered Color Palette Dictionary
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.palette.md
This class method returns an ordered dictionary of the colored palette. It is useful for understanding the color hierarchy.
```python
color_palette()
```
--------------------------------
### Load Stylesheet for Qt.Py
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the stylesheet for Qt.Py by specifying the Qt API using the Qt.__binding__ attribute.
```python
# Qt.Py
dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=Qt.__binding__)
```
--------------------------------
### Load QDarkStyle in C++
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Loads the stylesheet from a Qt resource file and applies it to the QApplication instance.
```cpp
// In your .pro file, add the resources
// RESOURCES += qdarkstyle/dark/darkstyle.qrc
#include
#include
#include
#include
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// Load dark theme stylesheet
QFile styleFile(":qdarkstyle/dark/darkstyle.qss");
if (!styleFile.exists()) {
qWarning("Unable to set stylesheet, file not found");
} else {
styleFile.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&styleFile);
QString stylesheet = ts.readAll();
app.setStyleSheet(stylesheet);
}
// For light theme, use:
// QFile lightStyleFile(":qdarkstyle/light/lightstyle.qss");
QMainWindow window;
window.setWindowTitle("QDarkStyle C++ Example");
window.resize(800, 600);
window.show();
return app.exec();
}
```
--------------------------------
### Apply QDarkStyleSheet with PyQt5
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Integration steps for PyQt5 applications using either the specific loader or the generic API.
```python
import sys
import qdarkstyle
from PyQt5 import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# or in new API
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))
# run
window.show()
app.exec_()
```
--------------------------------
### Generate distribution
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Creates source distribution and wheel files.
```bash
python setup.py sdist bdist_wheel
```
--------------------------------
### Loading Stylesheets
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Functions to load stylesheets for different Qt bindings (PyQt, PySide) and configurations.
```APIDOC
## qdarkstyle.load_stylesheet()
### Description
Loads the stylesheet, handling the import of the rc module. It supports specifying the Qt binding, or a custom palette.
### Method
`load_stylesheet(*args, **kwargs)`
### Parameters
#### Keyword Arguments
- **pyside** (bool) - Optional - True to load the PySide (or PySide2) rc file, False to load the PyQt4 (or PyQt5) rc file. Default is False.
- **qt_api** (str) - Optional - Qt binding name to set QT_API environment variable. Default is '', i.e PyQt5 the default QtPy binding. Possible values are pyside, pyside2 pyqt4, pyqt5. Not case sensitive.
- **palette** (Palette class) - Optional - Class (not instance) that inherits from Palette.
### Raises
- **TypeError** - If arguments do not match: type, keyword name nor quantity.
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_from_environment(is_pyqtgraph=False)
### Description
Loads the stylesheet from the QT_API (or PYQTGRAPH_QT_LIB) environment variable.
### Method
`load_stylesheet_from_environment(is_pyqtgraph=False)`
### Parameters
#### Path Parameters
- **is_pyqtgraph** (bool) - Optional - True if it is to be set using PYQTGRAPH_QT_LIB.
### Raises
- **KeyError** - if PYQTGRAPH_QT_LIB does not exist.
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_pyqt()
### Description
Loads the stylesheet for use in a PyQt4 application.
### Method
`load_stylesheet_pyqt()`
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_pyqt5()
### Description
Loads the stylesheet for use in a PyQt5 application.
### Method
`load_stylesheet_pyqt5()`
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_pyside2()
### Description
Loads the stylesheet for use in a PySide2 application.
### Method
`load_stylesheet_pyside2()`
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_pyside6()
### Description
Loads the stylesheet for use in a PySide6 application.
### Method
`load_stylesheet_pyside6()`
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet_pyqt6()
### Description
Loads the stylesheet for use in a PyQt6 application.
### Method
`load_stylesheet_pyqt6()`
### Returns
- the stylesheet string.
- **Return type:** str
## qdarkstyle.load_stylesheet()
### Description
Loads the stylesheet using the QtPy abstraction layer based on the environment variable.
### Method
`_load_stylesheet(qt_api='', palette=None)`
### Parameters
#### Path Parameters
- **qt_api** (str) - Optional - Qt binding name to set QT_API environment variable. Default is ‘’. Possible values are pyside, pyside2 pyqt4, pyqt5. Not case sensitive.
- **palette** (Palette) - Optional - Palette class that inherits from Palette.
### Note
- Note that the variable QT_API is read when first imported. So, pay attention to the import order.
- If you are using another abstraction layer, i.e PyQtGraph to do imports on Qt things you must set both to use the same Qt binding (PyQt, PySide).
- OS, binding and binding version number, and application-specific patches are applied in this order.
### Returns
- stylesheet string (css).
- **Return type:** str
```
--------------------------------
### Generate Themed Image Resources
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Automates the creation of PNG icons from SVG templates and generates Qt resource files.
```python
from qdarkstyle.utils.images import (
create_images,
create_palette_image,
generate_qrc_file,
compile_qrc_file,
convert_svg_to_png
)
from qdarkstyle.dark.palette import DarkPalette
from qdarkstyle.light.palette import LightPalette
import os
# Generate all PNG images from SVG templates for a palette
# Creates images for: normal, disabled, focus, pressed states
# At sizes: 32px (.png) and 64px (@2x.png)
create_images(palette=DarkPalette)
# Generate palette preview image
svg_path, png_path = create_palette_image(palette=DarkPalette)
print(f"Created palette SVG: {svg_path}")
print(f"Created palette PNG: {png_path}")
# Generate QRC resource file
generate_qrc_file(
resource_prefix='qss_icons',
style_prefix='qdarkstyle',
palette=DarkPalette
)
# Compile QRC to Python resource file
# compile_for options: 'qtpy', 'pyqt5', 'pyqt6', 'pyside2', 'pyside6', 'all'
compile_qrc_file(compile_for='qtpy', palette=DarkPalette)
```
--------------------------------
### Upload to official PyPI
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Uploads the distribution to the official PyPI repository.
```bash
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
```
--------------------------------
### qdarkstyle.load_stylesheet_pyqt6()
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Loads the qdarkstylesheet for use in a PyQt6 application.
```APIDOC
## qdarkstyle.load_stylesheet_pyqt6()
### Description
Load the stylesheet for use in a PyQt6 application.
### Method
GET
### Endpoint
/qdarkstyle/load_stylesheet_pyqt6
### Returns
- **stylesheet** (str) - The stylesheet string.
### Response Example
```
"""
/* qdarkstylesheet */
... (stylesheet content) ...
"""
```
```
--------------------------------
### Colorsystem Module
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/modules.md
Defines color constants used within the qdarkstyle package.
```APIDOC
## Colorsystem Module
### Description
Provides color definitions.
### Constants
#### `Blue`
- **Description**: Represents the blue color constant.
- **Type**: Not specified
#### `Gray`
- **Description**: Represents the gray color constant.
- **Type**: Not specified
```
--------------------------------
### Load Stylesheet using QtPy Abstraction
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the stylesheet using the QtPy abstraction layer, which automatically detects the Qt binding.
```python
# QtPy
dark_stylesheet = qdarkstyle.load_stylesheet()
```
--------------------------------
### Load QDarkStyleSheet using QtPy in Python
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
Set the QT_API environment variable to specify the Qt binding, then import from QtPy and load the QDarkStyleSheet.
```python
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to pyqt, pyqt5, pyside or pyside2 (not implemented yet)
# you do not need to use QtPy to set this variable
os.environ['QT_API'] = 'pyqt5'
# import from QtPy instead of doing it directly
# note that QtPy always uses PyQt5 API
from qtpy import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
# the default system in qdarkstyle uses qtpy environment variable
app.setStyleSheet(qdarkstyle.load_stylesheet())
# run
window.show()
app.exec_()
```
--------------------------------
### Clone QDarkStyleSheet Repository
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Clone the forked QDarkStyleSheet repository to your local machine. Replace USERNAME with your GitHub username.
```bash
git clone https://github.com/USERNAME/qdarkstyle
cd qdarkstyle
```
--------------------------------
### Upload to PyPI test
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Uploads the distribution to the PyPI test platform.
```bash
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
```
--------------------------------
### Access LightPalette Class
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Demonstrates accessing specific background, text, and accent colors from the LightPalette, and loading the stylesheet.
```python
from qdarkstyle.light.palette import LightPalette
import qdarkstyle
# Access palette ID
print(LightPalette.ID) # Output: 'light'
# Access background colors (light to dark)
print(LightPalette.COLOR_BACKGROUND_1) # '#FAFAFA' (lightest)
print(LightPalette.COLOR_BACKGROUND_2) # '#DFE1E2'
print(LightPalette.COLOR_BACKGROUND_3) # '#D2D5D8'
print(LightPalette.COLOR_BACKGROUND_4) # '#C0C4C8'
print(LightPalette.COLOR_BACKGROUND_5) # '#B4B8BC'
print(LightPalette.COLOR_BACKGROUND_6) # '#ACB1B6' (darkest)
# Access text colors (dark for light backgrounds)
print(LightPalette.COLOR_TEXT_1) # '#19232D' (primary text - dark)
print(LightPalette.COLOR_TEXT_2) # '#293544'
print(LightPalette.COLOR_TEXT_3) # '#54687A'
print(LightPalette.COLOR_TEXT_4) # '#788D9C'
# Access accent colors (lighter blues for light theme)
print(LightPalette.COLOR_ACCENT_1) # '#DAEDFF'
print(LightPalette.COLOR_ACCENT_2) # '#9FCBFF'
print(LightPalette.COLOR_ACCENT_3) # '#73C7FF'
# Load light stylesheet
stylesheet = qdarkstyle.load_stylesheet(palette=LightPalette)
```
--------------------------------
### Load Stylesheet for PyQt5
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the dark stylesheet specifically for PyQt5 applications.
```python
# PyQt5
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt5()
```
--------------------------------
### Convert SVG to PNG using QDarkStyleSheet
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Requires an active QApplication instance to perform the conversion. Specify the input SVG path, output PNG path, and desired dimensions.
```python
from qtpy.QtWidgets import QApplication
app = QApplication([])
convert_svg_to_png(
svg_path='path/to/icon.svg',
png_path='path/to/icon.png',
height=32,
width=32
)
```
--------------------------------
### Internal Settings Management
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.example.__main__.md
Functions for reading and writing window settings to a file using QSettings.
```APIDOC
## _read_settings(window, reset, QSettingsClass)
### Description
Reads and applies window settings from a configuration file.
### Parameters
- **window** (object) - The main window instance.
- **reset** (bool) - Flag to reset settings to default.
- **QSettingsClass** (class) - The Qt settings class to use.
## _write_settings(window, QSettingsClass)
### Description
Captures current window settings and persists them to a file.
### Parameters
- **window** (object) - The main window instance.
- **QSettingsClass** (class) - The Qt settings class to use.
```
--------------------------------
### Load Binding-Specific Stylesheets
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Use convenience functions to load stylesheets for specific Qt bindings without environment variable configuration. These are suitable for applications using a single, known binding.
```python
import sys
import qdarkstyle
# For PyQt5 applications
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# For PyQt6 applications
from PyQt6 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt6())
# For PySide2 applications
from PySide2 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside2())
# For PySide6 applications
from PySide6 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside6())
# For legacy PySide applications (deprecated)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside())
# For legacy PyQt4 applications (deprecated)
app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt())
```
--------------------------------
### Run UI CSS Edition Script
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Use this script to simplify the process of changing UI and CSS files. It creates a loop that restarts the application and processes UI and CSS files.
```bash
python scripts/run_ui_css_edition.py
```
--------------------------------
### Apply QDarkStyleSheet with PySide2
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Integration steps for PySide2 applications using either the specific loader or the generic API.
```python
import sys
import qdarkstyle
from PySide2 import QtWidgets
# create the application and the main window
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet_pyside2())
# or in new API
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyside2'))
# run
window.show()
app.exec_()
```
--------------------------------
### Load Stylesheet for PyQt6
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the dark stylesheet specifically for PyQt6 applications.
```python
# PyQt6
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt6()
```
--------------------------------
### qdarkstyle.load_stylesheet_pyside6()
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Loads the qdarkstylesheet for use in a PySide6 application.
```APIDOC
## qdarkstyle.load_stylesheet_pyside6()
### Description
Load the stylesheet for use in a PySide6 application.
### Method
GET
### Endpoint
/qdarkstyle/load_stylesheet_pyside6
### Returns
- **stylesheet** (str) - The stylesheet string.
### Response Example
```
"""
/* qdarkstylesheet */
... (stylesheet content) ...
"""
```
```
--------------------------------
### Load Stylesheet for PyQtGraph
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the stylesheet for PyQtGraph by specifying the Qt API via an environment variable.
```python
# PyQtGraph
dark_stylesheet = qdarkstyle.load_stylesheet(qt_api=os.environ('PYQTGRAPH_QT_LIB'))
```
--------------------------------
### Add QDarkStyleSheet resource file to .pro file (C++)
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
Include the QDarkStyleSheet resource file in your Qt C++ project's .pro file.
```c++
RESOURCES += qdarkstyle/THEME/THEMEstyle.qrc
```
--------------------------------
### Update project resources
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Updates auto-generated files like qss, rc files, and icons using PySide6.
```bash
python qdarkstyle\utils
```
--------------------------------
### Create Custom Palette
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Defines a custom theme by subclassing the base Palette class and provides methods to inspect the palette as a dictionary or color-only map.
```python
from qdarkstyle.palette import Palette
from qdarkstyle.colorsystem import Gray, Blue
import qdarkstyle
# Create a custom palette by subclassing Palette
class CustomPalette(Palette):
"""Custom purple-themed dark palette."""
ID = 'custom'
# Custom background colors
COLOR_BACKGROUND_1 = '#1a1a2e'
COLOR_BACKGROUND_2 = '#252542'
COLOR_BACKGROUND_3 = '#303055'
COLOR_BACKGROUND_4 = '#3b3b68'
COLOR_BACKGROUND_5 = '#46467b'
COLOR_BACKGROUND_6 = '#51518e'
# Text colors
COLOR_TEXT_1 = '#e0e0e0'
COLOR_TEXT_2 = '#c0c0c0'
COLOR_TEXT_3 = '#a0a0a0'
COLOR_TEXT_4 = '#808080'
# Purple accent colors
COLOR_ACCENT_1 = '#4a1a6b'
COLOR_ACCENT_2 = '#6b2d92'
COLOR_ACCENT_3 = '#9b59b6' # Primary accent
COLOR_ACCENT_4 = '#bb77d6'
COLOR_ACCENT_5 = '#db97f6'
COLOR_DISABLED = '#606060'
OPACITY_TOOLTIP = 230
# Convert palette to dictionary for inspection
palette_dict = CustomPalette.to_dict()
print("Full palette:")
for key, value in palette_dict.items():
print(f" {key}: {value}")
# Get only colors
colors_only = CustomPalette.color_palette()
print("\nColors only:")
for key, value in colors_only.items():
print(f" {key}: {value}")
```
--------------------------------
### qdarkstyle Package Functions
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/modules.md
This section details the main functions available in the qdarkstyle package for loading stylesheets.
```APIDOC
## qdarkstyle Package Functions
### Description
Provides functions to load stylesheets for Qt applications.
### Functions
#### `load_stylesheet()`
- **Description**: Loads the default dark stylesheet.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_from_environment()`
- **Description**: Loads a stylesheet based on environment variables.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyqt()`
- **Description**: Loads the stylesheet for PyQt applications.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyqt5()`
- **Description**: Loads the stylesheet specifically for PyQt5.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyqt6()`
- **Description**: Loads the stylesheet specifically for PyQt6.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyside()`
- **Description**: Loads the stylesheet for PySide applications.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyside2()`
- **Description**: Loads the stylesheet specifically for PySide2.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `load_stylesheet_pyside6()`
- **Description**: Loads the stylesheet specifically for PySide6.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
```
--------------------------------
### Load QDarkStyleSheet in C++ application
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/README.rst
Load the QDarkStyleSheet stylesheet into a Qt C++ application. Ensure the file path is correct and the file exists.
```c++
QFile f(":qdarkstyle/THEME/THEMEstyle.qss");
if (!f.exists()) {
printf("Unable to set stylesheet, file not found\n");
}
else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
```
--------------------------------
### Compile SCSS and Manage Palettes
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Utilities for generating QSS stylesheets from palette objects and converting between SCSS variables and dictionaries.
```python
from qdarkstyle.utils.scss import create_qss, _dict_to_scss, _scss_to_dict
from qdarkstyle.dark.palette import DarkPalette
from qdarkstyle.light.palette import LightPalette
# Compile QSS from palette (regenerates stylesheet files)
# This creates:
# - _variables.scss (from palette)
# - [palette.ID]style.qss (compiled stylesheet)
stylesheet = create_qss(palette=DarkPalette)
print(f"Generated stylesheet length: {len(stylesheet)} characters")
# Compile light theme
light_stylesheet = create_qss(palette=LightPalette)
# Convert palette dictionary to SCSS variables string
palette_dict = DarkPalette.to_dict()
scss_variables = _dict_to_scss(palette_dict)
print("SCSS Variables:")
print(scss_variables)
# Output:
# $ID: 'dark';
# $COLOR_BACKGROUND_6: #60798B;
# $COLOR_BACKGROUND_5: #54687A;
# ...
# Parse SCSS variables back to dictionary
parsed_dict = _scss_to_dict(scss_variables)
for key, value in parsed_dict.items():
print(f"{key}: {value}")
```
--------------------------------
### qdarkstyle.load_stylesheet_pyside2()
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Loads the qdarkstylesheet for use in a PySide2 application.
```APIDOC
## qdarkstyle.load_stylesheet_pyside2()
### Description
Load the stylesheet for use in a PySide2 application.
### Method
GET
### Endpoint
/qdarkstyle/load_stylesheet_pyside2
### Returns
- **stylesheet** (str) - The stylesheet string.
### Response Example
```
"""
/* qdarkstylesheet */
... (stylesheet content) ...
"""
```
```
--------------------------------
### qdarkstyle.load_stylesheet_pyside()
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Loads the qdarkstylesheet for use in a PySide application.
```APIDOC
## qdarkstyle.load_stylesheet_pyside()
### Description
Load the stylesheet for use in a PySide application.
### Method
GET
### Endpoint
/qdarkstyle/load_stylesheet_pyside
### Returns
- **stylesheet** (str) - The stylesheet string.
### Response Example
```
"""
/* qdarkstylesheet */
... (stylesheet content) ...
"""
```
```
--------------------------------
### Check distribution
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Validates the distribution package and README format.
```bash
twine check dist/*
```
--------------------------------
### Release via tox
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Uses the tox environment to automate the release and upload process.
```bash
tox -e release
```
--------------------------------
### Define qdarkstyle Palette Constants
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.palette.md
This snippet shows various constants defined within the qdarkstyle palette, including an ID, tooltip opacity, and resource path.
```python
ID *= None
```
```python
OPACITY_TOOLTIP *= 0
```
```python
PATH_RESOURCES *= ":'/qss_icons'"
```
--------------------------------
### Branch and Commit Management
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/contributing.md
Commands for creating feature branches, staging changes, committing with issue references, and pushing to the remote repository.
```bash
git checkout -b feature-xyz
```
```bash
git add .
```
```bash
git commit -m "Add useful new feature that does this, close #42"
git commit -m "Fix returning problem for get_style(), fix #78"
```
```bash
git push origin feature-xyz
```
--------------------------------
### Load QDarkStyleSheet in C++
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Load the QDarkStyleSheet stylesheet in a C++ Qt application by reading it from a resource file.
```c++
QFile f(":qdarkstyle/THEME/THEMEstyle.qss");
if (!f.exists()) {
printf("Unable to set stylesheet, file not found\n");
}
else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
```
--------------------------------
### Load QDarkStyleSheet Themes
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Apply dark or light themes to a Qt application using the main load_stylesheet function. This function supports automatic binding detection or explicit configuration via parameters.
```python
import sys
import os
import qdarkstyle
from qdarkstyle.dark.palette import DarkPalette
from qdarkstyle.light.palette import LightPalette
# Set the Qt API before importing Qt bindings
os.environ['QT_API'] = 'pyqt5'
from qtpy import QtWidgets
# Create application
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
window.setWindowTitle("QDarkStyle Example")
# Option 1: Load default dark stylesheet (auto-detects Qt binding)
stylesheet = qdarkstyle.load_stylesheet()
app.setStyleSheet(stylesheet)
# Option 2: Explicitly specify Qt API
stylesheet = qdarkstyle.load_stylesheet(qt_api='pyqt5')
app.setStyleSheet(stylesheet)
# Option 3: Load light theme using palette class
stylesheet = qdarkstyle.load_stylesheet(palette=LightPalette)
app.setStyleSheet(stylesheet)
# Option 4: Load dark theme using palette class
stylesheet = qdarkstyle.load_stylesheet(palette=DarkPalette)
app.setStyleSheet(stylesheet)
# Option 5: Combine qt_api and palette
stylesheet = qdarkstyle.load_stylesheet(qt_api='pyside6', palette=DarkPalette)
app.setStyleSheet(stylesheet)
window.show()
app.exec_()
```
--------------------------------
### Create New Working Branch
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Create a new branch for your feature or bug fix. Replace 'feature-xyz' with a descriptive branch name.
```bash
git checkout -b feature-xyz
```
--------------------------------
### Load Stylesheet from Environment Variable
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the stylesheet by reading the QT_API environment variable. This function is useful when using QtPy or similar abstraction layers.
```python
dark_stylesheet = qdarkstyle.load_stylesheet_from_environment()
```
--------------------------------
### Load Stylesheet for PySide6
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the dark stylesheet specifically for PySide6 applications.
```python
# PySide 6
dark_stylesheet = qdarkstyle.load_stylesheet_pyside6()
```
--------------------------------
### Add All Changed Files
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/CONTRIBUTING.rst
Stage all modified files in the repository for the next commit. This command adds all changes, including new, modified, and deleted files.
```bash
git add .
```
--------------------------------
### Palette Constants and Methods
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
This section lists the various color constants and methods available in the QDarkStylesheet palette for theme customization.
```APIDOC
## Palette Constants and Methods
### Description
This section lists the various color constants and methods available in the QDarkStylesheet palette for theme customization.
### Methods
#### `Palette.COLOR_TEXT_4`
- **Description**: Represents a specific text color constant.
#### `Palette.ID`
- **Description**: Represents an identifier constant.
#### `Palette.OPACITY_TOOLTIP`
- **Description**: Represents the opacity value for tooltips.
#### `Palette.PATH_RESOURCES`
- **Description**: Represents the path to resource files.
#### `Palette.SIZE_BORDER_RADIUS`
- **Description**: Represents the border radius size constant.
#### `Palette.W_STATUS_BAR_BACKGROUND_COLOR`
- **Description**: Represents the background color for the status bar.
#### `Palette.color_palette()`
- **Description**: Returns the current color palette.
#### `Palette.to_dict()`
- **Description**: Converts the color palette to a dictionary representation.
```
--------------------------------
### LightPalette Class Constants
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.light.palette.md
Accessing the color and configuration constants for the light theme palette.
```APIDOC
## LightPalette Class
### Description
Defines the theme variables for the QDarkStyle light palette.
### Constants
- **COLOR_ACCENT_1** (string) - '#DAEDFF'
- **COLOR_ACCENT_2** (string) - '#9FCBFF'
- **COLOR_ACCENT_3** (string) - '#73C7FF'
- **COLOR_ACCENT_4** (string) - '#37AEFE'
- **COLOR_ACCENT_5** (string) - '#259AE9'
- **COLOR_BACKGROUND_1** (string) - '#FAFAFA'
- **COLOR_BACKGROUND_2** (string) - '#DFE1E2'
- **COLOR_BACKGROUND_3** (string) - '#D2D5D8'
- **COLOR_BACKGROUND_4** (string) - '#C0C4C8'
- **COLOR_BACKGROUND_5** (string) - '#B4B8BC'
- **COLOR_BACKGROUND_6** (string) - '#ACB1B6'
- **COLOR_DISABLED** (string) - '#9DA9B5'
- **COLOR_TEXT_1** (string) - '#19232D'
- **COLOR_TEXT_2** (string) - '#293544'
- **COLOR_TEXT_3** (string) - '#54687A'
- **COLOR_TEXT_4** (string) - '#788D9C'
- **ID** (string) - 'light'
- **OPACITY_TOOLTIP** (int) - 230
```
--------------------------------
### Load Stylesheet for PyQt4
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the dark stylesheet specifically for PyQt4 applications. Note: PyQt4 is no longer supported.
```python
dark_stylesheet = qdarkstyle.load_stylesheet_pyqt()
```
--------------------------------
### Apply QDarkStyleSheet with PyQtGraph
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/readme.md
Configuration for using QDarkStyleSheet within a PyQtGraph environment.
```python
import sys
import qdarkstyle
import os
# set the environment variable to use a specific wrapper
# it can be set to PyQt, PyQt5, PySide or PySide2 (not implemented yet)
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
# import from pyqtgraph instead of doing it directly
# note that PyQtGraph always uses PyQt4 API
from pyqtgraph.Qt import QtGui
# create the application and the main window
app = QtGui.QApplication(sys.argv)
window = QtGui.QMainWindow()
# setup stylesheet
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api=os.environ['PYQTGRAPH_QT_LIB'])
# run
window.show()
app.exec_()
```
--------------------------------
### Internal Helper Functions
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/modules.md
Internal functions used by the qdarkstyle package for patching and loading.
```APIDOC
## Internal Helper Functions
### Description
Internal helper functions for applying patches and loading stylesheets.
### Functions
#### `_apply_application_patches()`
- **Description**: Applies patches to the application object.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `_apply_binding_patches()`
- **Description**: Applies patches related to Qt bindings.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `_apply_os_patches()`
- **Description**: Applies operating system specific patches.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `_apply_version_patches()`
- **Description**: Applies patches based on Qt version.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
#### `_load_stylesheet()`
- **Description**: Internal function to load the stylesheet content.
- **Method**: Not applicable (Python function)
- **Endpoint**: Not applicable
```
--------------------------------
### qdarkstyle.palette.Palette Class
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.palette.md
Defines the base palette mixin for qdarkstylesheet, containing various color, border, and layout constants.
```APIDOC
## Class: qdarkstyle.palette.Palette
### Description
Base palette mixin used to define the visual constants for the stylesheet, including background colors, accent colors, and border styles.
### Methods
#### color_palette()
- **Description**: Returns the ordered colored palette dictionary.
#### to_dict(colors_only=False)
- **Description**: Converts the palette variables into a dictionary format.
- **Parameters**:
- **colors_only** (bool) - Optional - If True, returns only color-related variables.
### Constants
- **BORDER_1, BORDER_2, BORDER_3** (str) - Border style definitions.
- **BORDER_SELECTION_1, BORDER_SELECTION_2, BORDER_SELECTION_3** (str) - Selection border style definitions.
- **COLOR_ACCENT_1-5** (str) - Accent color definitions.
- **COLOR_BACKGROUND_1-6** (str) - Background color definitions.
- **COLOR_TEXT_1-4** (str) - Text color definitions.
- **SIZE_BORDER_RADIUS** (str) - Default border radius size.
- **PATH_RESOURCES** (str) - Path to stylesheet resources.
```
--------------------------------
### Integrate with PyQtGraph
Source: https://context7.com/colinduquesnoy/qdarkstylesheet/llms.txt
Configures QDarkStyle to work with PyQtGraph by setting the appropriate environment variable and loading the stylesheet.
```python
import sys
import os
import qdarkstyle
# Set PyQtGraph to use PyQt5
os.environ['PYQTGRAPH_QT_LIB'] = 'PyQt5'
# Import from PyQtGraph's Qt wrapper
from pyqtgraph.Qt import QtGui, QtWidgets
# Create application
app = QtWidgets.QApplication(sys.argv)
# Load stylesheet using PyQtGraph's Qt binding
qt_api = os.environ.get('PYQTGRAPH_QT_LIB', 'PyQt5')
stylesheet = qdarkstyle.load_stylesheet(qt_api=qt_api)
app.setStyleSheet(stylesheet)
# Create main window with PyQtGraph plot
import pyqtgraph as pg
window = QtWidgets.QMainWindow()
window.setWindowTitle("PyQtGraph with QDarkStyle")
```
--------------------------------
### Load Stylesheet for PySide2
Source: https://github.com/colinduquesnoy/qdarkstylesheet/blob/master/docs/reference/qdarkstyle.md
Load the dark stylesheet specifically for PySide2 applications.
```python
# PySide 2
dark_stylesheet = qdarkstyle.load_stylesheet_pyside2()
```