{"id":13415428,"url":"https://github.com/spyder-ide/qtsass","last_synced_at":"2025-04-05T17:07:53.323Z","repository":{"id":36504409,"uuid":"40810092","full_name":"spyder-ide/qtsass","owner":"spyder-ide","description":"Compile SASS files to Qt stylesheets","archived":false,"fork":false,"pushed_at":"2023-09-11T20:56:58.000Z","size":201,"stargazers_count":125,"open_issues_count":7,"forks_count":37,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-05-23T03:21:08.231Z","etag":null,"topics":["css","qt","qt-stylesheets","sass","sass-compiler"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spyder-ide.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null},"funding":{"open_collective":"spyder"}},"created_at":"2015-08-16T10:22:05.000Z","updated_at":"2024-05-11T16:02:46.000Z","dependencies_parsed_at":"2024-04-18T19:59:52.300Z","dependency_job_id":null,"html_url":"https://github.com/spyder-ide/qtsass","commit_stats":{"total_commits":173,"total_committers":13,"mean_commits":"13.307692307692308","dds":0.6184971098265897,"last_synced_commit":"ba36f6106b39b3deaf3af8873dbf7c876ee9ce1f"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyder-ide%2Fqtsass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyder-ide%2Fqtsass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyder-ide%2Fqtsass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spyder-ide%2Fqtsass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spyder-ide","download_url":"https://codeload.github.com/spyder-ide/qtsass/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247369952,"owners_count":20927928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","qt","qt-stylesheets","sass","sass-compiler"],"created_at":"2024-07-30T21:00:48.637Z","updated_at":"2025-04-05T17:07:53.304Z","avatar_url":"https://github.com/spyder-ide.png","language":"Python","funding_links":["https://opencollective.com/spyder","https://opencollective.com/spyder/"],"categories":["editor"],"sub_categories":[],"readme":"# QtSASS: Compile SCSS files to Qt stylesheets\n\n[![License - MIT](https://img.shields.io/github/license/spyder-ide/qtsass.svg)](./LICENSE.txt)\n[![OpenCollective Backers](https://opencollective.com/spyder/backers/badge.svg?color=blue)](#backers)\n[![Join the chat at https://gitter.im/spyder-ide/public](https://badges.gitter.im/spyder-ide/spyder.svg)](https://gitter.im/spyder-ide/public)\u003cbr\u003e\n[![Github build status](https://github.com/spyder-ide/qtsass/workflows/Tests/badge.svg)](https://github.com/spyder-ide/qtsass/actions)\n[![Codecov coverage](https://img.shields.io/codecov/c/github/spyder-ide/qtsass/master.svg)](https://codecov.io/gh/spyder-ide/qtsass)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spyder-ide/qtsass/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spyder-ide/qtsass/?branch=master)\n\n*Copyright © 2015 Yann Lanthony*\n\n*Copyright © 2017–2018 Spyder Project Contributors*\n\n\n## Overview\n\n[SASS](http://sass-lang.com/) brings countless amazing features to CSS.\nBesides being used in web development, CSS is also the way to stylize Qt-based desktop applications.\nHowever, Qt's CSS has a few variations that prevent the direct use of SASS compiler.\n\nThe purpose of this tool is to fill the gap between SASS and Qt-CSS by handling those variations.\n\n\n## Qt's CSS specificities\n\nThe goal of QtSASS is to be able to generate a Qt-CSS stylesheet based on a 100% valid SASS file.\nThis is how it deals with Qt's specifics and how you should modify your CSS stylesheet to use QtSASS.\n\n#### \"!\" in selectors\nQt allows to define the style of a widget according to its states, like this:\n\n```css\nQLineEdit:enabled {\n...\n}\n```\n\nHowever, a \"not\" state is problematic because it introduces an exclamation mark in the selector's name, which is not valid SASS/CSS:\n\n```css\nQLineEdit:!editable {\n...\n}\n```\n\nQtSASS allows \"!\" in selectors' names; the SASS file is preprocessed and any occurence of `:!` is replaced by `:_qnot_` (for \"Qt not\").\nHowever, using this feature prevents from having a 100% valid SASS file, so this support of `!` might change in the future.\nThis can be replaced by the direct use of the `_qnot_` keyword in your SASS file:\n\n```css\nQLineEdit:_qnot_editable { /* will generate QLineEdit:!editable { */\n...\n}\n```\n\n#### qlineargradient\nThe qlineargradient function also has a non-valid CSS syntax.\n\n```css\nqlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.1 blue, stop: 0.8 green)\n```\n\nTo support qlineargradient QtSASS provides a preprocessor and a SASS implementation of the qlineargradient function. The above QSS syntax will be replaced with the following:\n\n```css\nqlineargradient(0, 0, 0, 1, (0.1 blue, 0.8 green))\n```\n\nYou may also use this syntax directly in your QtSASS.\n\n```\nqlineargradient(0, 0, 0, 1, (0.1 blue, 0.8 green))\n# the stops parameter is a list, so you can also use variables:\n$stops = 0.1 blue, 0.8 green\nqlineargradient(0, 0, 0, 0, $stops)\n```\n\n#### qrgba\nQt's rgba:\n\n```css\nrgba(255, 128, 128, 50%)\n```\n\nis replaced by CSS rgba:\n\n```css\nrgba(255, 128, 128, 0.5)\n```\n\n\n## Executable usage\n\nTo compile your SASS stylesheet to a Qt compliant CSS file:\n\n```bash\n# If -o is omitted, output will be printed to console\nqtsass style.scss -o style.css\n```\n\nTo use the watch mode and get your stylesheet auto recompiled on each file save:\n\n```bash\n# If -o is omitted, output will be print to console\nqtsass style.scss -o style.css -w\n```\n\nTo compile a directory containing SASS stylesheets to Qt compliant CSS files:\n\n```bash\nqtsass ./static/scss -o ./static/css\n```\n\nYou can also use watch mode to watch the entire directory for changes.\n\n```bash\nqtsass ./static/scss -o ./static/css -w\n```\n\nSet the Environment Variable QTSASS_DEBUG to 1 or pass the --debug flag to enable logging.\n\n```bash\nqtsass ./static/scss -o ./static/css --debug\n```\n\n## API methods\n\n### `compile(string, **kwargs)`\n\nConform and Compile QtSASS source code to CSS.\n\nThis function conforms QtSASS to valid SCSS before passing it to\nsass.compile. Any keyword arguments you provide will be combined with\nqtsass's default keyword arguments and passed to sass.compile.\n\nExamples:\n\n```bash\n\u003e\u003e\u003e import qtsass\n\u003e\u003e\u003e qtsass.compile(\"QWidget {background: rgb(0, 0, 0);}\")\nQWidget {background:black;}\n```\n\nArguments:\n- string: QtSASS source code to conform and compile.\n- kwargs: Keyword arguments to pass to sass.compile\n\nReturns:\n- Qt compliant CSS string\n\n### `compile_filename(input_file, output_file=None, **kwargs)`:\n\nCompile and return a QtSASS file as Qt compliant CSS. Optionally save to a file.\n\nExamples:\n\n```bash\n\u003e\u003e\u003e import qtsass\n\u003e\u003e\u003e qtsass.compile_filename(\"dummy.scss\", \"dummy.css\")\n\u003e\u003e\u003e css = qtsass.compile_filename(\"dummy.scss\")\n```\n\nArguments:\n- input_file: Path to QtSass file.\n- output_file: Path to write Qt compliant CSS.\n- kwargs: Keyword arguments to pass to sass.compile\n\nReturns:\n- Qt compliant CSS string\n\n### `compile_dirname(input_dir, output_dir, **kwargs)`:\n\nCompiles QtSASS files in a directory including subdirectories.\n\n```bash\n\u003e\u003e\u003e import qtsass\n\u003e\u003e\u003e qtsass.compile_dirname(\"./scss\", \"./css\")\n```\n\nArguments:\n- input_dir: Path to directory containing QtSass files.\n- output_dir: Directory to write compiled Qt compliant CSS files to.\n- kwargs: Keyword arguments to pass to sass.compile\n\n### `enable_logging(level=None, handler=None)`:\nEnable logging for qtsass.\n\nSets the qtsass logger's level to:\n    1. the provided logging level\n    2. logging.DEBUG if the QTSASS_DEBUG envvar is a True value\n    3. logging.WARNING\n\n```bash\n\u003e\u003e\u003e import logging\n\u003e\u003e\u003e import qtsass\n\u003e\u003e\u003e handler = logging.StreamHandler()\n\u003e\u003e\u003e formatter = logging.Formatter('%(level)-8s: %(name)s\u003e %(message)s')\n\u003e\u003e\u003e handler.setFormatter(formatter)\n\u003e\u003e\u003e qtsass.enable_logging(level=logging.DEBUG, handler=handler)\n```\n\nArguments:\n- level: Optional logging level\n- handler: Optional handler to add\n\n### `watch(source, destination, compiler=None, Watcher=None)`:\nWatches a source file or directory, compiling QtSass files when modified.\n\nThe compiler function defaults to compile_filename when source is a file\nand compile_dirname when source is a directory.\n\nArguments:\n- source: Path to source QtSass file or directory.\n- destination: Path to output css file or directory.\n- compiler: Compile function (optional)\n- Watcher: Defaults to qtsass.watchers.Watcher (optional)\n\nReturns:\n- qtsass.watchers.Watcher instance\n\n## Contributing\n\nEveryone is welcome to contribute!\n\n\n## Sponsors\n\nSpyder and its subprojects are funded thanks to the generous support of\n\n[![Quansight](https://static.wixstatic.com/media/095d2c_2508c560e87d436ea00357abc404cf1d~mv2.png/v1/crop/x_0,y_9,w_915,h_329/fill/w_380,h_128,al_c,usm_0.66_1.00_0.01/095d2c_2508c560e87d436ea00357abc404cf1d~mv2.png)](https://www.quansight.com/)[![Numfocus](https://i2.wp.com/numfocus.org/wp-content/uploads/2017/07/NumFocus_LRG.png?fit=320%2C148\u0026ssl=1)](https://numfocus.org/)\n\n\nand the donations we have received from our users around the world through [Open Collective](https://opencollective.com/spyder/):\n\n[![Sponsors](https://opencollective.com/spyder/sponsors.svg)](https://opencollective.com/spyder#support)\n\nPlease consider becoming a sponsor!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspyder-ide%2Fqtsass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspyder-ide%2Fqtsass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspyder-ide%2Fqtsass/lists"}