{"id":24496,"library":"qstylizer","title":"Qstylizer","description":"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.","status":"maintenance","version":"0.2.4","language":"python","source_language":"en","source_url":"https://github.com/blambright/qstylizer","tags":["qt","pyside","pyqt","qss","stylesheet","generator"],"install":[{"cmd":"pip install qstylizer","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Runtime dependency: used for QSS generation and stylesheet application","package":"PyQt5","optional":false}],"imports":[{"note":"Direct import from qstylizer doesn't expose StyleSheet; use the style submodule.","wrong":"from qstylizer import StyleSheet","symbol":"StyleSheet","correct":"from qstylizer.style import StyleSheet"}],"quickstart":{"code":"from qstylizer.style import StyleSheet\n\n# Create a stylesheet for a QPushButton\nss = StyleSheet()\nss.QPushButton.setBackgroundColor('red')\nss.QPushButton.setColor('white')\nss.QPushButton.setBorderRadius('5px')\n\n# Compile to QSS string\nqss = ss.toString()\nprint(qss)\n# Output: QPushButton { background-color: red; color: white; border-radius: 5px; }","lang":"python","description":"Create a stylesheet object, apply properties to widgets, and compile to QSS string."},"warnings":[{"fix":"Call .copy() on the StyleSheet instance before mutating if you need isolation.","message":"StyleSheet 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.","severity":"gotcha","affected_versions":"all versions"},{"fix":"Double-check property names in the generated QSS; use Qt documentation for correct CSS property names.","message":"Property 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.","severity":"gotcha","affected_versions":"all versions"},{"fix":"Use __setitem__ with raw selectors: ss['QPushButton:hover']['background-color'] = 'blue'","message":"The 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.","severity":"gotcha","affected_versions":"all versions"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from qstylizer.style import StyleSheet","cause":"StyleSheet is not exposed at the top-level; it lives in qstylizer.style.","error":"ImportError: cannot import name 'StyleSheet' from 'qstylizer'"},{"fix":"Ensure you use the exact class name (e.g., QPushButton) and call the attribute correctly: ss.QPushButton.setBackgroundColor('red')","cause":"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.","error":"AttributeError: 'StyleSheet' object has no attribute 'QPushButton'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}