Registry / serialization / qstylizer

qstylizer

JSON →
library0.2.4pypypi✓ verified 86d ago

Qstylizer is a Python library that generates Qt stylesheets (QSS) programmatically. It provides a clean, Pythonic API for creating and composing styles for PyQt4/5 and PySide1/2 applications. Current version 0.2.4, with irregular releases; last release in 2018.

pip install qstylizer
INSTALL
IMPORT
SIG · QSTYLIZER
Q
qstylizer
serializationpythonv0.2.4
Install
1.7s avg
Import
10ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.2.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 18.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.008s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StyleSheet
from qstylizer.style import StyleSheet
from qstylizer import StyleSheet
Direct import from qstylizer doesn't expose StyleSheet; use the style submodule.

Create a stylesheet object, apply properties to widgets, and compile to QSS string.

from qstylizer.style import StyleSheet # Create a stylesheet for a QPushButton ss = StyleSheet() ss.QPushButton.setBackgroundColor('red') ss.QPushButton.setColor('white') ss.QPushButton.setBorderRadius('5px') # Compile to QSS string qss = ss.toString() print(qss) # Output: QPushButton { background-color: red; color: white; border-radius: 5px; }
Debug
Known issues
gotchaStyleSheet objects are mutable and reuse the same internal dictionary. Modifying a returned StyleSheet (e.g., from a property) may affect the original. Use .copy() if you need an independent instance.
fix
Call .copy() on the StyleSheet instance before mutating if you need isolation.
affects: all versions
gotchaProperty names use camelCase style (e.g., setBackgroundColor, setBorderRadius) but output CSS properties follow Qt conventional kebab-case after compilation. There is no built-in validation; misspellings will pass silently and produce no effect.
fix
Double-check property names in the generated QSS; use Qt documentation for correct CSS property names.
affects: all versions
gotchaThe library does not support pseudo-states (e.g., :hover) or sub-controls (e.g., ::drop-down) directly. Complex selectors must be built manually, which often leads to confusion.
fix
Use __setitem__ with raw selectors: ss['QPushButton:hover']['background-color'] = 'blue'
affects: all versions
Errors
Common errors & fixes
ImportError: cannot import name 'StyleSheet' from 'qstylizer'
StyleSheet is not exposed at the top-level; it lives in qstylizer.style.
fix
Use: from qstylizer.style import StyleSheet
AttributeError: 'StyleSheet' object has no attribute 'QPushButton'
The StyleSheet object dynamically creates attributes based on widget names; if the attribute doesn't exist, it means the widget name is misspelled or not yet accessed.
fix
Ensure you use the exact class name (e.g., QPushButton) and call the attribute correctly: ss.QPushButton.setBackgroundColor('red')
Upgrade
Version history
0.2.4latest on PyPI · released Nov 20, 2024
Audit
Dependencies
PyQt5requiredRuntime dependency: used for QSS generation and stylesheet application
Agent activity
2 hits · last 30 days
node
2
Resources
qstylizer — pip install qstylizer · libregistry