Skip to main content
https://travis-ci.com/blambright/qstylizer.svg?branch=master https://readthedocs.org/projects/qstylizer/badge/?version=latest

Installation

pip install qstylizer

Documentation

Read the Docs.

Introduction

qstylizer is a python package designed to help with the construction of PyQt/PySide stylesheets.

import PyQt5.QtWidgets

import qstylizer.style

css = qstylizer.style.StyleSheet()
css.setValues(
    backgroundColor="green",
    color="#F0F0F0",
    marginLeft="2px"
)
css.QToolButton.setValues(
    border="1px transparent lightblue",
    borderRadius="3px",
    margin="1px",
    padding="3px"
)
css.QToolButton.menuButton.pressed.setValues(
    border="1px solid #333333",
    padding="5px",
    backgroundColor="#333333"
)
# The following is also valid and is equivalent to the statement above.
css["QToolButton::menu-button:pressed"].setValues(**{
    "border": "1px solid #333333",
    "padding": "5px",
    "background-color": "#333333",
})

css.QCheckBox.disabled.backgroundColor.setValue("#797979")

widget = PyQt5.QtWidgets.QWidget()
widget.setStyleSheet(css.toString())

The stylesheet generated above looks like this when passed to setStyleSheet():

* {
    color: #F0F0F0;
    margin-left: 2px;
    background-color: green;
}
QToolButton {
    border-radius: 3px;
    padding: 3px;
    border: 1px transparent lightblue;
    margin: 1px;
}
QToolButton::menu-button:pressed {
    padding: 5px;
    border: 1px solid #333333;
    background-color: #333333;
}
QCheckBox:disabled {
    background-color: #797979;
}

The true power comes from parsing an existing stylesheet and tweaking individual property values.

import qstylizer.parser

css = qstylizer.parser.parse(
    """
    QToolButton::menu-button:pressed {
        padding: 5px;
        border: 1px solid #333333;
        background-color: #333333;
    }
    QCheckBox:disabled {
        background-color: #797979;
    }
    """
)
css.QToolButton.menuButton.pressed.padding.setValue("10px")
css.QCheckBox.disabled.backgroundColor.setValue("#222222")

print(css.toString())

Output:

QToolButton::menu-button:pressed {
    padding: 10px;
    border: 1px solid #333333;
    background-color: #333333;
}
QCheckBox:disabled {
    background-color: #222222;
}

License

MIT License

Copyright (c) 2018 Brett Lambright

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for qstylizer 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qstylizer 0.2.4
File Size Uploaded
qstylizer-0.2.4.tar.gz 25.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qstylizer 0.2.4
File Interpreter ABI Platform
qstylizer-0.2.4-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 40.8 kB

Release files / qstylizer-0.2.4.tar.gz

Download URL qstylizer-0.2.4.tar.gz
Size 25.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4880991d912c9837454832e8e2b58d60b66848d8c4a7cf57ed544fd68b91a23a
BLAKE2b-256 checksum
How to use checksums
41f18714c35fcebabe591756a868416b968e4da457b02bbfcb3a451cafbf6f9d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.7

Release files / qstylizer-0.2.4-py2.py3-none-any.whl

Download URL qstylizer-0.2.4-py2.py3-none-any.whl
Size 15.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8f384dfe86f9edb0bb596b93663a51f124f0794b94fd54057cc7cf9cea59fb6f
BLAKE2b-256 checksum
How to use checksums
2dba2a4e51861942c2bc3be60400c69f6713359c3e307aee4696f2ea47f35811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page