├── .gitignore ├── .travis.yml ├── CONTRIBUTING.rst ├── HISTORY.rst ├── LICENSE ├── MANIFEST.in ├── README.rst ├── appveyor.yml ├── docs ├── Makefile ├── conf.py ├── history.rst ├── index.rst ├── installation.rst ├── make.bat ├── readme.rst └── usage.rst ├── environment.yml ├── qt_style_sheet_inspector ├── __init__.py └── _inspector.py ├── requirements_dev.txt ├── setup.cfg ├── setup.py ├── tests ├── __init__.py └── test_qt_style_sheet_inspector.py ├── tox.ini └── travis_pypi_setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | 27 | # PyInstaller 28 | # Usually these files are written by a python script from a template 29 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 30 | *.manifest 31 | *.spec 32 | 33 | # Installer logs 34 | pip-log.txt 35 | pip-delete-this-directory.txt 36 | 37 | # Unit test / coverage reports 38 | htmlcov/ 39 | .tox/ 40 | .coverage 41 | .coverage.* 42 | .cache 43 | nosetests.xml 44 | coverage.xml 45 | *,cover 46 | .hypothesis/ 47 | 48 | # Translations 49 | *.mo 50 | *.pot 51 | 52 | # Django stuff: 53 | *.log 54 | 55 | # Sphinx documentation 56 | docs/_build/ 57 | 58 | # PyBuilder 59 | target/ 60 | 61 | # PyCharm files 62 | .idea/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | install: 4 | - pip install --upgrade --pre tox 5 | 6 | env: 7 | matrix: 8 | - TOXENV=py36 9 | jobs: 10 | include: 11 | - env: TOXENV=py35 12 | python: '3.5' 13 | 14 | - env: TOXENV=py36 15 | python: '3.6' 16 | 17 | - env: TOXENV=py37 18 | python: 'nightly' 19 | 20 | - stage: deploy 21 | python: '3.6' 22 | env: 23 | install: pip install -U setuptools setuptools_scm 24 | script: skip 25 | deploy: 26 | provider: pypi 27 | user: williamjamir 28 | distributions: sdist bdist_wheel 29 | skip_upload_docs: true 30 | password: 31 | secure: CJUEv0ggJe3DmjDs5c57KpdH442vUeIiAK55w6fQKk4RXpJOABUNLefTqxdNGgwxcQ1zBj73rj+sphaa7HspY/RkKeFa23tObQvOiTBOin3AOYQkWESNSEkZx+yfIMgDSlS1yDwvo/fIeItg1LTa75ybV5jXlCGR7esEnN/krDYfWHbcRoVh3Mk10qnp9VfBUsguwOSYll85l+44FFctqyrWrKHl1YhP26/OQ0ITw/6CN9TJw+GnDg16CjpAVjPXg9H/qS+zExWe6dGkyRsMndjs6/flhiXYOUdnTu9Nx4Aa7/Jsv8BwMHLw4bURVvsy/d4Cllmips0Z9OZ/UoLvRpPT/Ezg1DXj0VM/G7Ftjfwdq0FpIpoCXvgydQhPe2lLDHTsH+lr0CDGuHiQQiCiFqpHqUzpNxe0XCxAsFGtoeup1WMU9PmZveN4ujZMMQsJ3YDs/2M1MwAgtQsPDqW70DqBrtOf6V62DnrkIaAHZV4CE3yzCb3LYhTFWNTF0B/4okEtpEVj2VmaW8L+otM9/Mw1K4Ygg8sfwSRBCpHe0ezJ8/IC7gqlPtPXLip5eQQ26Brf84ulq3dsMANEKTTRVz5pBkG6JvIbec60Bd1Zo1ToxqkwRK6+0yXLScTQTZ3ftU7HIFQyVKQVxpDAThthg8xYlPbXq4kOh21dD05DVf8= 32 | on: 33 | tags: true 34 | repo: ESSS/qt_style_sheet_inspector 35 | 36 | script: tox --recreate 37 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every little bit 8 | helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/ESSS/qt_style_sheet_inspector/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" and "help 30 | wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | qt_style_sheet_inspector could always use more documentation, whether as part of the 42 | official qt_style_sheet_inspector docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/ESSS/qt_style_sheet_inspector/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | Get Started! 58 | ------------ 59 | 60 | Ready to contribute? Here's how to set up `qt_style_sheet_inspector` for local development. 61 | 62 | 1. Fork the `qt_style_sheet_inspector` repo on GitHub. 63 | 2. Clone your fork locally:: 64 | 65 | $ git clone git@github.com:your_name_here/qt_style_sheet_inspector.git 66 | 67 | 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:: 68 | 69 | $ mkvirtualenv qt_style_sheet_inspector 70 | $ cd qt_style_sheet_inspector/ 71 | $ python setup.py develop 72 | 73 | 4. Create a branch for local development:: 74 | 75 | $ git checkout -b name-of-your-bugfix-or-feature 76 | 77 | Now you can make your changes locally. 78 | 79 | 5. When you're done making changes, check that your changes pass flake8 and the 80 | tests, including testing other Python versions with tox:: 81 | 82 | $ flake8 qt_style_sheet_inspector tests 83 | $ python setup.py test or py.test 84 | $ tox 85 | 86 | To get flake8 and tox, just pip install them into your virtualenv. 87 | 88 | 6. Commit your changes and push your branch to GitHub:: 89 | 90 | $ git add . 91 | $ git commit -m "Your detailed description of your changes." 92 | $ git push origin name-of-your-bugfix-or-feature 93 | 94 | 7. Submit a pull request through the GitHub website. 95 | 96 | Pull Request Guidelines 97 | ----------------------- 98 | 99 | Before you submit a pull request, check that it meets these guidelines: 100 | 101 | 1. The pull request should include tests. 102 | 2. If the pull request adds functionality, the docs should be updated. Put 103 | your new functionality into a function with a docstring, and add the 104 | feature to the list in README.rst. 105 | 3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check 106 | https://travis-ci.org/ESSS/qt_style_sheet_inspector/pull_requests 107 | and make sure that the tests pass for all supported Python versions. 108 | 109 | Tips 110 | ---- 111 | 112 | To run a subset of tests:: 113 | 114 | $ py.test tests.test_qt_style_sheet_inspector 115 | 116 | 117 | Deploying 118 | --------- 119 | 120 | A reminder for the maintainers on how to deploy. 121 | Make sure all your changes are committed (including an entry in HISTORY.rst). 122 | Then run:: 123 | 124 | $ bumpversion patch # possible: major / minor / patch 125 | $ git push 126 | $ git push --tags 127 | 128 | Travis will then deploy to PyPI if tests pass. 129 | -------------------------------------------------------------------------------- /HISTORY.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | History 3 | ======= 4 | 5 | 0.1.0 (2016-09-28) 6 | ------------------ 7 | 8 | * First release. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2016, Rafael Bertoldi 5 | 6 | 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: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | 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. 11 | 12 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | 2 | include HISTORY.rst 3 | include LICENSE 4 | include README.rst 5 | 6 | recursive-include tests * 7 | recursive-exclude * __pycache__ 8 | recursive-exclude * *.py[co] 9 | 10 | recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif 11 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | 2 | ======================== 3 | Qt Style Sheet Inspector 4 | ======================== 5 | 6 | .. image:: https://img.shields.io/travis/ESSS/qt_style_sheet_inspector.svg 7 | :target: https://travis-ci.org/ESSS/qt_style_sheet_inspector 8 | 9 | .. image:: https://img.shields.io/appveyor/ci/ESSS/qt-style-sheet-inspector/master.svg 10 | :target: https://ci.appveyor.com/project/ESSS/qt-style-sheet-inspector 11 | 12 | .. image:: https://img.shields.io/pypi/v/qt_style_sheet_inspector.svg 13 | :target: https://pypi.python.org/pypi/qt_style_sheet_inspector 14 | 15 | .. image:: https://img.shields.io/conda/vn/conda-forge/qt_style_sheet_inspector.svg 16 | :target: https://anaconda.org/conda-forge/qt_style_sheet_inspector 17 | 18 | .. image:: https://img.shields.io/pypi/pyversions/qt_style_sheet_inspector.svg 19 | :target: https://pypi.python.org/pypi/qt_style_sheet_inspector 20 | 21 | 22 | An inspector widget to view and modify the style sheet of a Qt app at runtime. 23 | 24 | 25 | Usage 26 | ----- 27 | 28 | In order to use the inspector widget on your application, it's necessary to initialize the class :code:`style_sheet_inspector_class` passing the instance of the :code:`QMainWindow` from the application. 29 | 30 | The repository demo_qt_inspector_ contains a full example of a Qt Application with an inspector widget being called by a shortcut action. 31 | 32 | .. _demo_qt_inspector: https://github.com/williamjamir/demo_qt_inspector 33 | 34 | 35 | See the demo in action: 36 | 37 | .. image:: https://github.com/williamjamir/demo_qt_inspector/blob/master/images/qt_inspector_demo.gif 38 | :width: 10px 39 | :height: 10px 40 | :scale: 10 % 41 | 42 | 43 | Features 44 | -------- 45 | View current style sheet of an application during runtime 46 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | 48 | The inspector only checks for style sheets that were applied to the QApplication, it's the topmost and any change here can be propagated to all children. 49 | 50 | Style sheets that applied to an individual widget will not appear on the inspector. 51 | 52 | 53 | Style sheet can be changed at runtime (Pressing CTRL+S) 54 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 55 | 56 | .. image:: https://github.com/williamjamir/demo_qt_inspector/blob/master/images/qt_inspector_runtime_changes.gif 57 | :width: 10px 58 | :height: 10px 59 | :scale: 10 % 60 | 61 | Search bar to help find specific types or names (Pressing F3) 62 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 63 | .. image:: https://github.com/williamjamir/demo_qt_inspector/blob/master/images/qt_inspector_search.gif 64 | :width: 10px 65 | :height: 10px 66 | :scale: 10 % 67 | 68 | Can undo/redo changes (Pressing CTRL+ALT+Z or CTRL+ALT+Y) 69 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 70 | 71 | .. image:: https://github.com/williamjamir/demo_qt_inspector/blob/master/images/qt_inspector_undo_redo.gif 72 | :width: 10px 73 | :height: 10px 74 | :scale: 10 % 75 | 76 | Observation 77 | ----------- 78 | 79 | It needs PyQt5 to work, but it doesn't have it as a dependency. 80 | 81 | * Free software: MIT license 82 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | skip_branch_with_pr: true 2 | 3 | environment: 4 | matrix: 5 | - PYTHON: C:\Python35 6 | TOX_ENV: py35 7 | 8 | - PYTHON: C:\Python36 9 | TOX_ENV: py36 10 | 11 | install: 12 | - "%PYTHON%/python.exe -m pip install -U pip tox wheel" 13 | 14 | build: false # Not a C# project 15 | 16 | test_script: 17 | - "%PYTHON%/Scripts/tox -e %TOX_ENV%" 18 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # User-friendly check for sphinx-build 11 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 12 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 13 | endif 14 | 15 | # Internal variables. 16 | PAPEROPT_a4 = -D latex_paper_size=a4 17 | PAPEROPT_letter = -D latex_paper_size=letter 18 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 19 | # the i18n builder cannot share the environment and doctrees with the others 20 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 21 | 22 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 23 | 24 | help: 25 | @echo "Please use \`make ' where is one of" 26 | @echo " html to make standalone HTML files" 27 | @echo " dirhtml to make HTML files named index.html in directories" 28 | @echo " singlehtml to make a single large HTML file" 29 | @echo " pickle to make pickle files" 30 | @echo " json to make JSON files" 31 | @echo " htmlhelp to make HTML files and a HTML help project" 32 | @echo " qthelp to make HTML files and a qthelp project" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | 49 | clean: 50 | rm -rf $(BUILDDIR)/* 51 | 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | dirhtml: 58 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 59 | @echo 60 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 61 | 62 | singlehtml: 63 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 64 | @echo 65 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 66 | 67 | pickle: 68 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 69 | @echo 70 | @echo "Build finished; now you can process the pickle files." 71 | 72 | json: 73 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 74 | @echo 75 | @echo "Build finished; now you can process the JSON files." 76 | 77 | htmlhelp: 78 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 79 | @echo 80 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 81 | ".hhp project file in $(BUILDDIR)/htmlhelp." 82 | 83 | qthelp: 84 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 85 | @echo 86 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 87 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 88 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/qt_style_sheet_inspector.qhcp" 89 | @echo "To view the help file:" 90 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/qt_style_sheet_inspector.qhc" 91 | 92 | devhelp: 93 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 94 | @echo 95 | @echo "Build finished." 96 | @echo "To view the help file:" 97 | @echo "# mkdir -p $$HOME/.local/share/devhelp/qt_style_sheet_inspector" 98 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/qt_style_sheet_inspector" 99 | @echo "# devhelp" 100 | 101 | epub: 102 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 103 | @echo 104 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 105 | 106 | latex: 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo 109 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 110 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 111 | "(use \`make latexpdf' here to do that automatically)." 112 | 113 | latexpdf: 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through pdflatex..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | latexpdfja: 120 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 121 | @echo "Running LaTeX files through platex and dvipdfmx..." 122 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 123 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 124 | 125 | text: 126 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 127 | @echo 128 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 129 | 130 | man: 131 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 132 | @echo 133 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 134 | 135 | texinfo: 136 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 137 | @echo 138 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 139 | @echo "Run \`make' in that directory to run these through makeinfo" \ 140 | "(use \`make info' here to do that automatically)." 141 | 142 | info: 143 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 144 | @echo "Running Texinfo files through makeinfo..." 145 | make -C $(BUILDDIR)/texinfo info 146 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 147 | 148 | gettext: 149 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 150 | @echo 151 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 152 | 153 | changes: 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 160 | @echo 161 | @echo "Link check complete; look for any errors in the above output " \ 162 | "or in $(BUILDDIR)/linkcheck/output.txt." 163 | 164 | doctest: 165 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 166 | @echo "Testing of doctests in the sources finished, look at the " \ 167 | "results in $(BUILDDIR)/doctest/output.txt." 168 | 169 | xml: 170 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 171 | @echo 172 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 173 | 174 | pseudoxml: 175 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 176 | @echo 177 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 178 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # qt_style_sheet_inspector documentation build configuration file, created by 5 | # sphinx-quickstart on Tue Jul 9 22:26:36 2013. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | import sys 17 | import os 18 | 19 | # If extensions (or modules to document with autodoc) are in another 20 | # directory, add these directories to sys.path here. If the directory is 21 | # relative to the documentation root, use os.path.abspath to make it 22 | # absolute, like shown here. 23 | #sys.path.insert(0, os.path.abspath('.')) 24 | 25 | # Get the project root dir, which is the parent dir of this 26 | cwd = os.getcwd() 27 | project_root = os.path.dirname(cwd) 28 | 29 | # Insert the project root dir as the first element in the PYTHONPATH. 30 | # This lets us ensure that the source package is imported, and that its 31 | # version is used. 32 | sys.path.insert(0, project_root) 33 | 34 | import qt_style_sheet_inspector 35 | 36 | # -- General configuration --------------------------------------------- 37 | 38 | # If your documentation needs a minimal Sphinx version, state it here. 39 | #needs_sphinx = '1.0' 40 | 41 | # Add any Sphinx extension module names here, as strings. They can be 42 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 43 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] 44 | 45 | # Add any paths that contain templates here, relative to this directory. 46 | templates_path = ['_templates'] 47 | 48 | # The suffix of source filenames. 49 | source_suffix = '.rst' 50 | 51 | # The encoding of source files. 52 | #source_encoding = 'utf-8-sig' 53 | 54 | # The master toctree document. 55 | master_doc = 'index' 56 | 57 | # General information about the project. 58 | project = u'Qt Style Sheet Inspector' 59 | copyright = u"2016, Rafael Bertoldi" 60 | 61 | # The version info for the project you're documenting, acts as replacement 62 | # for |version| and |release|, also used in various other places throughout 63 | # the built documents. 64 | # 65 | # The short X.Y version. 66 | version = qt_style_sheet_inspector.__version__ 67 | # The full version, including alpha/beta/rc tags. 68 | release = qt_style_sheet_inspector.__version__ 69 | 70 | # The language for content autogenerated by Sphinx. Refer to documentation 71 | # for a list of supported languages. 72 | #language = None 73 | 74 | # There are two options for replacing |today|: either, you set today to 75 | # some non-false value, then it is used: 76 | #today = '' 77 | # Else, today_fmt is used as the format for a strftime call. 78 | #today_fmt = '%B %d, %Y' 79 | 80 | # List of patterns, relative to source directory, that match files and 81 | # directories to ignore when looking for source files. 82 | exclude_patterns = ['_build'] 83 | 84 | # The reST default role (used for this markup: `text`) to use for all 85 | # documents. 86 | #default_role = None 87 | 88 | # If true, '()' will be appended to :func: etc. cross-reference text. 89 | #add_function_parentheses = True 90 | 91 | # If true, the current module name will be prepended to all description 92 | # unit titles (such as .. function::). 93 | #add_module_names = True 94 | 95 | # If true, sectionauthor and moduleauthor directives will be shown in the 96 | # output. They are ignored by default. 97 | #show_authors = False 98 | 99 | # The name of the Pygments (syntax highlighting) style to use. 100 | pygments_style = 'sphinx' 101 | 102 | # A list of ignored prefixes for module index sorting. 103 | #modindex_common_prefix = [] 104 | 105 | # If true, keep warnings as "system message" paragraphs in the built 106 | # documents. 107 | #keep_warnings = False 108 | 109 | 110 | # -- Options for HTML output ------------------------------------------- 111 | 112 | # The theme to use for HTML and HTML Help pages. See the documentation for 113 | # a list of builtin themes. 114 | html_theme = 'default' 115 | 116 | # Theme options are theme-specific and customize the look and feel of a 117 | # theme further. For a list of options available for each theme, see the 118 | # documentation. 119 | #html_theme_options = {} 120 | 121 | # Add any paths that contain custom themes here, relative to this directory. 122 | #html_theme_path = [] 123 | 124 | # The name for this set of Sphinx documents. If None, it defaults to 125 | # " v documentation". 126 | #html_title = None 127 | 128 | # A shorter title for the navigation bar. Default is the same as 129 | # html_title. 130 | #html_short_title = None 131 | 132 | # The name of an image file (relative to this directory) to place at the 133 | # top of the sidebar. 134 | #html_logo = None 135 | 136 | # The name of an image file (within the static path) to use as favicon 137 | # of the docs. This file should be a Windows icon file (.ico) being 138 | # 16x16 or 32x32 pixels large. 139 | #html_favicon = None 140 | 141 | # Add any paths that contain custom static files (such as style sheets) 142 | # here, relative to this directory. They are copied after the builtin 143 | # static files, so a file named "default.css" will overwrite the builtin 144 | # "default.css". 145 | # html_static_path = ['_static'] 146 | 147 | # If not '', a 'Last updated on:' timestamp is inserted at every page 148 | # bottom, using the given strftime format. 149 | #html_last_updated_fmt = '%b %d, %Y' 150 | 151 | # If true, SmartyPants will be used to convert quotes and dashes to 152 | # typographically correct entities. 153 | #html_use_smartypants = True 154 | 155 | # Custom sidebar templates, maps document names to template names. 156 | #html_sidebars = {} 157 | 158 | # Additional templates that should be rendered to pages, maps page names 159 | # to template names. 160 | #html_additional_pages = {} 161 | 162 | # If false, no module index is generated. 163 | #html_domain_indices = True 164 | 165 | # If false, no index is generated. 166 | #html_use_index = True 167 | 168 | # If true, the index is split into individual pages for each letter. 169 | #html_split_index = False 170 | 171 | # If true, links to the reST sources are added to the pages. 172 | #html_show_sourcelink = True 173 | 174 | # If true, "Created using Sphinx" is shown in the HTML footer. 175 | # Default is True. 176 | #html_show_sphinx = True 177 | 178 | # If true, "(C) Copyright ..." is shown in the HTML footer. 179 | # Default is True. 180 | #html_show_copyright = True 181 | 182 | # If true, an OpenSearch description file will be output, and all pages 183 | # will contain a tag referring to it. The value of this option 184 | # must be the base URL from which the finished HTML is served. 185 | #html_use_opensearch = '' 186 | 187 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 188 | #html_file_suffix = None 189 | 190 | # Output file base name for HTML help builder. 191 | htmlhelp_basename = 'qt_style_sheet_inspectordoc' 192 | 193 | 194 | # -- Options for LaTeX output ------------------------------------------ 195 | 196 | latex_elements = { 197 | # The paper size ('letterpaper' or 'a4paper'). 198 | #'papersize': 'letterpaper', 199 | 200 | # The font size ('10pt', '11pt' or '12pt'). 201 | #'pointsize': '10pt', 202 | 203 | # Additional stuff for the LaTeX preamble. 204 | #'preamble': '', 205 | } 206 | 207 | # Grouping the document tree into LaTeX files. List of tuples 208 | # (source start file, target name, title, author, documentclass 209 | # [howto/manual]). 210 | latex_documents = [ 211 | ('index', 'qt_style_sheet_inspector.tex', 212 | u'Qt Style Sheet Inspector Documentation', 213 | u'Rafael Bertoldi', 'manual'), 214 | ] 215 | 216 | # The name of an image file (relative to this directory) to place at 217 | # the top of the title page. 218 | #latex_logo = None 219 | 220 | # For "manual" documents, if this is true, then toplevel headings 221 | # are parts, not chapters. 222 | #latex_use_parts = False 223 | 224 | # If true, show page references after internal links. 225 | #latex_show_pagerefs = False 226 | 227 | # If true, show URL addresses after external links. 228 | #latex_show_urls = False 229 | 230 | # Documents to append as an appendix to all manuals. 231 | #latex_appendices = [] 232 | 233 | # If false, no module index is generated. 234 | #latex_domain_indices = True 235 | 236 | 237 | # -- Options for manual page output ------------------------------------ 238 | 239 | # One entry per manual page. List of tuples 240 | # (source start file, name, description, authors, manual section). 241 | man_pages = [ 242 | ('index', 'qt_style_sheet_inspector', 243 | u'Qt Style Sheet Inspector Documentation', 244 | [u'Rafael Bertoldi'], 1) 245 | ] 246 | 247 | # If true, show URL addresses after external links. 248 | #man_show_urls = False 249 | 250 | 251 | # -- Options for Texinfo output ---------------------------------------- 252 | 253 | # Grouping the document tree into Texinfo files. List of tuples 254 | # (source start file, target name, title, author, 255 | # dir menu entry, description, category) 256 | texinfo_documents = [ 257 | ('index', 'qt_style_sheet_inspector', 258 | u'Qt Style Sheet Inspector Documentation', 259 | u'Rafael Bertoldi', 260 | 'qt_style_sheet_inspector', 261 | 'One line description of project.', 262 | 'Miscellaneous'), 263 | ] 264 | 265 | # Documents to append as an appendix to all manuals. 266 | #texinfo_appendices = [] 267 | 268 | # If false, no module index is generated. 269 | #texinfo_domain_indices = True 270 | 271 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 272 | #texinfo_show_urls = 'footnote' 273 | 274 | # If true, do not generate a @detailmenu in the "Top" node's menu. 275 | #texinfo_no_detailmenu = False 276 | -------------------------------------------------------------------------------- /docs/history.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../HISTORY.rst 2 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. qt_style_sheet_inspector documentation master file, created by 2 | sphinx-quickstart on Tue Jul 9 22:26:36 2013. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to Qt Style Sheet Inspector's documentation! 7 | ====================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | readme 15 | installation 16 | usage 17 | history 18 | 19 | Indices and tables 20 | ================== 21 | 22 | * :ref:`genindex` 23 | * :ref:`modindex` 24 | * :ref:`search` 25 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Installation 5 | ============ 6 | 7 | 8 | Stable release 9 | -------------- 10 | 11 | To install Qt Style Sheet Inspector, run this command in your terminal: 12 | 13 | .. code-block:: console 14 | 15 | $ pip install qt_style_sheet_inspector 16 | 17 | This is the preferred method to install Qt Style Sheet Inspector, as it will always install the most recent stable release. 18 | 19 | If you don't have `pip`_ installed, this `Python installation guide`_ can guide 20 | you through the process. 21 | 22 | .. _pip: https://pip.pypa.io 23 | .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ 24 | 25 | 26 | From sources 27 | ------------ 28 | 29 | The sources for Qt Style Sheet Inspector can be downloaded from the `Github repo`_. 30 | 31 | You can either clone the public repository: 32 | 33 | .. code-block:: console 34 | 35 | $ git clone git://github.com/ESSS/qt_style_sheet_inspector 36 | 37 | Or download the `tarball`_: 38 | 39 | .. code-block:: console 40 | 41 | $ curl -OL https://github.com/ESSS/qt_style_sheet_inspector/tarball/master 42 | 43 | Once you have a copy of the source, you can install it with: 44 | 45 | .. code-block:: console 46 | 47 | $ python setup.py install 48 | 49 | 50 | .. _Github repo: https://github.com/ESSS/qt_style_sheet_inspector 51 | .. _tarball: https://github.com/ESSS/qt_style_sheet_inspector/tarball/master 52 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | 50 | %SPHINXBUILD% 2> nul 51 | if errorlevel 9009 ( 52 | echo. 53 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 54 | echo.installed, then set the SPHINXBUILD environment variable to point 55 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 56 | echo.may add the Sphinx directory to PATH. 57 | echo. 58 | echo.If you don't have Sphinx installed, grab it from 59 | echo.http://sphinx-doc.org/ 60 | exit /b 1 61 | ) 62 | 63 | if "%1" == "html" ( 64 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 65 | if errorlevel 1 exit /b 1 66 | echo. 67 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 68 | goto end 69 | ) 70 | 71 | if "%1" == "dirhtml" ( 72 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 73 | if errorlevel 1 exit /b 1 74 | echo. 75 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 76 | goto end 77 | ) 78 | 79 | if "%1" == "singlehtml" ( 80 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 81 | if errorlevel 1 exit /b 1 82 | echo. 83 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 84 | goto end 85 | ) 86 | 87 | if "%1" == "pickle" ( 88 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 89 | if errorlevel 1 exit /b 1 90 | echo. 91 | echo.Build finished; now you can process the pickle files. 92 | goto end 93 | ) 94 | 95 | if "%1" == "json" ( 96 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 97 | if errorlevel 1 exit /b 1 98 | echo. 99 | echo.Build finished; now you can process the JSON files. 100 | goto end 101 | ) 102 | 103 | if "%1" == "htmlhelp" ( 104 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 105 | if errorlevel 1 exit /b 1 106 | echo. 107 | echo.Build finished; now you can run HTML Help Workshop with the ^ 108 | .hhp project file in %BUILDDIR%/htmlhelp. 109 | goto end 110 | ) 111 | 112 | if "%1" == "qthelp" ( 113 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 117 | .qhcp project file in %BUILDDIR%/qthelp, like this: 118 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\qt_style_sheet_inspector.qhcp 119 | echo.To view the help file: 120 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\qt_style_sheet_inspector.ghc 121 | goto end 122 | ) 123 | 124 | if "%1" == "devhelp" ( 125 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 126 | if errorlevel 1 exit /b 1 127 | echo. 128 | echo.Build finished. 129 | goto end 130 | ) 131 | 132 | if "%1" == "epub" ( 133 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 134 | if errorlevel 1 exit /b 1 135 | echo. 136 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 137 | goto end 138 | ) 139 | 140 | if "%1" == "latex" ( 141 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 142 | if errorlevel 1 exit /b 1 143 | echo. 144 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 145 | goto end 146 | ) 147 | 148 | if "%1" == "latexpdf" ( 149 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 150 | cd %BUILDDIR%/latex 151 | make all-pdf 152 | cd %BUILDDIR%/.. 153 | echo. 154 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 155 | goto end 156 | ) 157 | 158 | if "%1" == "latexpdfja" ( 159 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 160 | cd %BUILDDIR%/latex 161 | make all-pdf-ja 162 | cd %BUILDDIR%/.. 163 | echo. 164 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 165 | goto end 166 | ) 167 | 168 | if "%1" == "text" ( 169 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 170 | if errorlevel 1 exit /b 1 171 | echo. 172 | echo.Build finished. The text files are in %BUILDDIR%/text. 173 | goto end 174 | ) 175 | 176 | if "%1" == "man" ( 177 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 178 | if errorlevel 1 exit /b 1 179 | echo. 180 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 181 | goto end 182 | ) 183 | 184 | if "%1" == "texinfo" ( 185 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 186 | if errorlevel 1 exit /b 1 187 | echo. 188 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 189 | goto end 190 | ) 191 | 192 | if "%1" == "gettext" ( 193 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 194 | if errorlevel 1 exit /b 1 195 | echo. 196 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 197 | goto end 198 | ) 199 | 200 | if "%1" == "changes" ( 201 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 202 | if errorlevel 1 exit /b 1 203 | echo. 204 | echo.The overview file is in %BUILDDIR%/changes. 205 | goto end 206 | ) 207 | 208 | if "%1" == "linkcheck" ( 209 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 210 | if errorlevel 1 exit /b 1 211 | echo. 212 | echo.Link check complete; look for any errors in the above output ^ 213 | or in %BUILDDIR%/linkcheck/output.txt. 214 | goto end 215 | ) 216 | 217 | if "%1" == "doctest" ( 218 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 219 | if errorlevel 1 exit /b 1 220 | echo. 221 | echo.Testing of doctests in the sources finished, look at the ^ 222 | results in %BUILDDIR%/doctest/output.txt. 223 | goto end 224 | ) 225 | 226 | if "%1" == "xml" ( 227 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 228 | if errorlevel 1 exit /b 1 229 | echo. 230 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 231 | goto end 232 | ) 233 | 234 | if "%1" == "pseudoxml" ( 235 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 236 | if errorlevel 1 exit /b 1 237 | echo. 238 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 239 | goto end 240 | ) 241 | 242 | :end 243 | -------------------------------------------------------------------------------- /docs/readme.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../README.rst 2 | -------------------------------------------------------------------------------- /docs/usage.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Usage 3 | ===== 4 | 5 | To use Qt Style Sheet Inspector in a project:: 6 | 7 | import qt_style_sheet_inspector 8 | -------------------------------------------------------------------------------- /environment.yml: -------------------------------------------------------------------------------- 1 | name: qt_style_sheet_inspector 2 | 3 | dependencies: 4 | - pyqt5>=5.5 5 | - pytest 6 | - pytest-mock 7 | - pytest-qt 8 | 9 | environment: 10 | - PYTHONPATH: 11 | - {{ root }} 12 | -------------------------------------------------------------------------------- /qt_style_sheet_inspector/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from __future__ import absolute_import, division, print_function, \ 4 | unicode_literals 5 | 6 | from ._inspector import StyleSheetInspector 7 | 8 | __version__ = '0.1.0' 9 | 10 | __all__ = ['StyleSheetInspector'] 11 | -------------------------------------------------------------------------------- /qt_style_sheet_inspector/_inspector.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from __future__ import absolute_import, division, print_function, \ 4 | unicode_literals 5 | 6 | from textwrap import dedent 7 | 8 | from PyQt5.QtCore import QEvent, Qt 9 | from PyQt5.QtGui import QKeySequence, QTextCursor 10 | from PyQt5.QtWidgets import QDialog, QHBoxLayout, QLineEdit, QMessageBox, \ 11 | QPushButton, QShortcut, QTextEdit, QVBoxLayout, QWidget, qApp 12 | 13 | 14 | class StyleSheetInspector(QDialog): 15 | """ 16 | An inspector window that tries to aid developers inspecting current style 17 | sheet used by a Qt application. 18 | 19 | It provides a few features: 20 | 21 | * a search bar to search for occurrences in style sheet 22 | * apply style sheet changes to app in run time, without the necessity of 23 | regenerating Qt resource files for every change in QSS, which can 24 | speed the design of a style sheet a lot. 25 | * undo/redo of applied style sheets 26 | 27 | Press `F1` to see all available shortcuts. 28 | 29 | About code style 30 | ---------------- 31 | 32 | Since it is an specialization of a Qt widget, it reuses its code style so 33 | its API is consistent. 34 | 35 | Known issues 36 | ------------ 37 | 38 | * Inspector window still reuses app style sheet, which can be annoying 39 | when testing styles. Is there a way to avoid reusing style sheets? 40 | 41 | Reference 42 | --------- 43 | 44 | Inspired by 45 | http://doc.qt.io/qt-5/qtwidgets-widgets-stylesheet-example.html. 46 | """ 47 | 48 | def __init__(self, parent=None): 49 | QDialog.__init__(self, parent) 50 | 51 | self.setWindowTitle('Qt Style Sheet Inspector') 52 | self.widget = StyleSheetWidget() 53 | 54 | layout = QHBoxLayout() 55 | layout.addWidget(self.widget) 56 | self.setLayout(layout) 57 | 58 | def event(self, event): 59 | """ 60 | Overridden to show shortcuts on `?` button of dialog. 61 | """ 62 | if event.type() == QEvent.EnterWhatsThisMode: 63 | from PyQt5.QtWidgets import QWhatsThis 64 | QWhatsThis.leaveWhatsThisMode() 65 | self.widget.onHelp() 66 | return True 67 | return QDialog.event(self, event) 68 | 69 | 70 | class StyleSheetWidget(QWidget): 71 | 72 | def __init__(self, parent=None): 73 | QWidget.__init__(self, parent) 74 | self.tape = [] 75 | self.tape_pos = -1 76 | 77 | self.style_sheet = None 78 | 79 | self.search_bar = QLineEdit(self) 80 | self.search_bar.textChanged.connect(self.onSearchTextChanged) 81 | 82 | self.style_text_edit = QTextEdit(self) 83 | self.style_text_edit.textChanged.connect(self.onStyleTextChanged) 84 | # To prevent messing with contents when pasted from an IDE, for 85 | # instance. 86 | self.style_text_edit.setAcceptRichText(False) 87 | 88 | self.apply_button = QPushButton('Apply', self) 89 | self.apply_button.clicked.connect(self.onApplyButton) 90 | 91 | layout = QVBoxLayout(self) 92 | layout.addWidget(self.search_bar) 93 | layout.addWidget(self.style_text_edit) 94 | layout.addWidget(self.apply_button) 95 | self.setLayout(layout) 96 | 97 | next_hit_shortcut = QShortcut(QKeySequence(Qt.Key_F3), self) 98 | next_hit_shortcut.activated.connect(self.onNextSearchHit) 99 | 100 | search_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F), self) 101 | search_shortcut.activated.connect(self.onFocusSearchBar) 102 | 103 | apply_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_S), self) 104 | apply_shortcut.activated.connect(self.applyStyleSheet) 105 | 106 | undo_shortcut = QShortcut( 107 | QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Z), self) 108 | undo_shortcut.activated.connect(self.onUndo) 109 | 110 | redo_shortcut = QShortcut( 111 | QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Y), self) 112 | redo_shortcut.activated.connect(self.onRedo) 113 | 114 | help_shortcut = QShortcut( 115 | QKeySequence(Qt.Key_F1), self) 116 | help_shortcut.activated.connect(self.onHelp) 117 | 118 | self.loadStyleSheet() 119 | 120 | def onUndo(self, checked=False): 121 | """ 122 | Undo last applied style sheet, if there is any. 123 | """ 124 | assert self.tape_pos >= 0 125 | if self.tape_pos == 0: 126 | return 127 | self.tape_pos -= 1 128 | self.style_text_edit.setPlainText(self.tape[self.tape_pos]) 129 | self.applyStyleSheet(stateless=True) 130 | 131 | def onRedo(self, checked=False): 132 | """ 133 | Redo last reverted style sheet, if there is any. 134 | """ 135 | assert self.tape_pos >= 0 136 | if self.tape_pos == len(self.tape) - 1: 137 | return 138 | self.tape_pos += 1 139 | self.style_text_edit.setPlainText(self.tape[self.tape_pos]) 140 | self.applyStyleSheet(stateless=True) 141 | 142 | def onHelp(self): 143 | """ 144 | Shows a dialog with available shortcuts. 145 | """ 146 | msg_box = QMessageBox(self) 147 | msg_box.setWindowTitle("Help") 148 | msg_box.setText("Available shortcuts:") 149 | msg_box.setInformativeText(dedent("""\ 150 | F1: show help dialog 151 | Ctrl+S: apply current changes 152 | Ctrl+F: go to search bar 153 | F3: go to next search hit 154 | Ctrl+Alt+Z: revert to last applied style sheet 155 | Ctrl+Alt+Y: redo last reverted style sheet 156 | """)) 157 | msg_box.setStandardButtons(QMessageBox.Ok) 158 | msg_box.setDefaultButton(QMessageBox.Ok) 159 | msg_box.exec_() 160 | 161 | def onSearchTextChanged(self, text): 162 | """ 163 | When search bar text changes, try to find text in style sheet text. 164 | If there is a match, color search bar text green, otherwise goes back 165 | to start of style sheet text and text is colored red. 166 | """ 167 | search = self.search_bar.text() 168 | if not self.style_text_edit.find(search): 169 | self.search_bar.setStyleSheet("color: red;") 170 | self.style_text_edit.moveCursor(QTextCursor.Start) 171 | else: 172 | self.search_bar.setStyleSheet("color: green;") 173 | 174 | def onNextSearchHit(self): 175 | """ 176 | Goes to next match to search text. If there isn't any, cycles back to 177 | first occurrence. 178 | """ 179 | search = self.search_bar.text() 180 | if not self.style_text_edit.find(search): 181 | # Cycle back to first hit 182 | self.style_text_edit.moveCursor(QTextCursor.Start) 183 | self.style_text_edit.find(search) 184 | 185 | def onFocusSearchBar(self): 186 | """ 187 | Focus search bar. 188 | """ 189 | self.search_bar.setFocus() 190 | 191 | def onStyleTextChanged(self): 192 | """ 193 | Enable apply button when there are style text changes. 194 | """ 195 | self.apply_button.setEnabled(True) 196 | 197 | def onApplyButton(self, checked=False): 198 | """ 199 | Apply style sheet changes in running app when apply button pressed. 200 | """ 201 | self.applyStyleSheet() 202 | 203 | def loadStyleSheet(self): 204 | """ 205 | Load app style sheet and displays its text in inspector widget. 206 | """ 207 | style_sheet = self.style_sheet = qApp.styleSheet() 208 | self.tape.append(style_sheet) 209 | self.tape_pos = 0 210 | 211 | self.style_text_edit.setPlainText(style_sheet) 212 | self.apply_button.setEnabled(False) 213 | 214 | def applyStyleSheet(self, stateless=False): 215 | """ 216 | Apply style sheet changes in running app. 217 | 218 | :param bool stateless: If true, style sheet state tape isn't updated. 219 | """ 220 | self.style_sheet = self.style_text_edit.toPlainText() 221 | qApp.setStyleSheet(self.style_sheet) 222 | if not stateless: 223 | if self.tape_pos + 1 < len(self.tape): 224 | self.tape = self.tape[:self.tape_pos + 1] 225 | self.tape.append(self.style_sheet) 226 | self.tape_pos += 1 227 | self.apply_button.setEnabled(False) 228 | -------------------------------------------------------------------------------- /requirements_dev.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | pytest-qt 3 | pytest-mock 4 | pytest-xvfb 5 | PyQt5 6 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | [bumpversion:file:qt_style_sheet_inspector/__init__.py] 11 | search = __version__ = '{current_version}' 12 | replace = __version__ = '{new_version}' 13 | 14 | [bdist_wheel] 15 | universal = 1 16 | 17 | [flake8] 18 | exclude = docs 19 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from setuptools import setup 5 | 6 | with open('README.rst') as readme_file: 7 | readme = readme_file.read() 8 | 9 | with open('HISTORY.rst') as history_file: 10 | history = history_file.read() 11 | 12 | requirements = [] 13 | 14 | setup( 15 | name='qt_style_sheet_inspector', 16 | version='0.1.0', 17 | description="A inspector widget to view and modify style sheet of a Qt app in runtime.", 18 | long_description=readme + '\n\n' + history, 19 | author="Rafael Bertoldi", 20 | author_email='tochaman@gmail.com', 21 | url='https://github.com/ESSS/qt_style_sheet_inspector', 22 | packages=[ 23 | 'qt_style_sheet_inspector', 24 | ], 25 | package_dir={'qt_style_sheet_inspector': 26 | 'qt_style_sheet_inspector'}, 27 | include_package_data=True, 28 | install_requires=requirements, 29 | license="MIT license", 30 | zip_safe=False, 31 | keywords='qt_style_sheet_inspector', 32 | classifiers=[ 33 | 'Development Status :: 2 - Pre-Alpha', 34 | 'Intended Audience :: Developers', 35 | 'License :: OSI Approved :: MIT License', 36 | 'Natural Language :: English', 37 | 'Programming Language :: Python :: 3', 38 | 'Programming Language :: Python :: 3.4', 39 | 'Programming Language :: Python :: 3.5', 40 | 'Programming Language :: Python :: 3.6', 41 | 'Programming Language :: Python :: 3.7', 42 | ], 43 | test_suite='tests', 44 | tests_require=[], 45 | ) 46 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /tests/test_qt_style_sheet_inspector.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from __future__ import absolute_import, division, print_function, \ 5 | unicode_literals 6 | 7 | import pytest 8 | from PyQt5.QtWidgets import qApp 9 | from qt_style_sheet_inspector import StyleSheetInspector 10 | 11 | 12 | def test_load_style_sheet(inspector): 13 | """ 14 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 15 | """ 16 | assert inspector.widget.style_text_edit.toPlainText() == qApp.styleSheet() 17 | 18 | 19 | def test_apply(inspector): 20 | """ 21 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 22 | """ 23 | assert not inspector.widget.apply_button.isEnabled() 24 | inspector.widget.style_text_edit.setPlainText(qApp.styleSheet() + """\ 25 | QLabel { 26 | font-size: 14px; 27 | } 28 | """) 29 | assert inspector.widget.apply_button.isEnabled() 30 | inspector.widget.apply_button.click() 31 | assert inspector.widget.style_text_edit.toPlainText() == qApp.styleSheet() 32 | assert not inspector.widget.apply_button.isEnabled() 33 | 34 | 35 | def test_search_hit(inspector): 36 | """ 37 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 38 | """ 39 | # keyClick only works if window is shown 40 | inspector.show() 41 | 42 | assert inspector.widget.style_text_edit.textCursor().position() == 0 43 | 44 | # there are 3 occurrences of "0px" in style sheet, after that it should 45 | # cycle back to first occurrence 46 | inspector.widget.search_bar.setText("0px") 47 | assert inspector.widget.search_bar.styleSheet() == "color: green;" 48 | assert inspector.widget.style_text_edit.textCursor().position() == 35 49 | 50 | inspector.widget.onNextSearchHit() 51 | assert inspector.widget.search_bar.styleSheet() == "color: green;" 52 | assert inspector.widget.style_text_edit.textCursor().position() == 61 53 | 54 | inspector.widget.onNextSearchHit() 55 | assert inspector.widget.search_bar.styleSheet() == "color: green;" 56 | assert inspector.widget.style_text_edit.textCursor().position() == 86 57 | 58 | inspector.widget.onNextSearchHit() 59 | assert inspector.widget.search_bar.styleSheet() == "color: green;" 60 | assert inspector.widget.style_text_edit.textCursor().position() == 35 61 | 62 | 63 | def test_search_miss(inspector): 64 | """ 65 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 66 | """ 67 | # keyClick only works if window is shown 68 | inspector.show() 69 | 70 | assert inspector.widget.style_text_edit.textCursor().position() == 0 71 | 72 | inspector.widget.search_bar.setText("INVALID") 73 | assert inspector.widget.search_bar.styleSheet() == "color: red;" 74 | assert inspector.widget.style_text_edit.textCursor().position() == 0 75 | 76 | inspector.widget.onNextSearchHit() 77 | assert inspector.widget.search_bar.styleSheet() == "color: red;" 78 | assert inspector.widget.style_text_edit.textCursor().position() == 0 79 | 80 | 81 | def test_focus_search_bar(inspector, mocker): 82 | """ 83 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 84 | :type mocker: pytest_mock.MockFixture 85 | """ 86 | # keyClick only works if window is shown 87 | inspector.show() 88 | 89 | # testing focus is unreliable, especially when using multiprocessing 90 | mocker.patch.object(inspector.widget.search_bar, 'setFocus') 91 | inspector.widget.onFocusSearchBar() 92 | inspector.widget.search_bar.setFocus.assert_called_once_with() 93 | 94 | 95 | def test_undo_redo(inspector): 96 | """ 97 | :type inspector: qt_style_sheet_inspector.StyleSheetInspector 98 | """ 99 | # keyClick only works if window is shown 100 | inspector.show() 101 | 102 | style_sheets = [qApp.styleSheet()] 103 | 104 | # Undo before changes doesn't have any effect 105 | inspector.widget.onUndo() 106 | assert inspector.widget.style_text_edit.toPlainText() == style_sheets[-1] 107 | 108 | # Undo after changes 109 | inspector.widget.style_text_edit.setPlainText(qApp.styleSheet() + """\ 110 | QLabel { 111 | font-size: 14px; 112 | } 113 | """) 114 | inspector.widget.apply_button.click() 115 | current = qApp.styleSheet() 116 | assert inspector.widget.style_text_edit.toPlainText() == current 117 | assert current != style_sheets[-1] 118 | style_sheets.append(current) 119 | 120 | inspector.widget.onUndo() 121 | assert inspector.widget.style_text_edit.toPlainText() == style_sheets[-2] 122 | 123 | # Redo 124 | inspector.widget.onRedo() 125 | assert inspector.widget.style_text_edit.toPlainText() == style_sheets[-1] 126 | 127 | # Redo again, won't have any effect 128 | inspector.widget.onRedo() 129 | assert inspector.widget.style_text_edit.toPlainText() == style_sheets[-1] 130 | 131 | # Undo, change again then try to redo, won't have any effect, as state 132 | # tape has been updated 133 | inspector.widget.onUndo() 134 | inspector.widget.style_text_edit.setPlainText(qApp.styleSheet() + """\ 135 | QPushButton { 136 | background-color: #dcdddf; 137 | } 138 | """) 139 | inspector.widget.apply_button.click() 140 | current = qApp.styleSheet() 141 | assert inspector.widget.style_text_edit.toPlainText() == current 142 | assert current != style_sheets[-1] 143 | style_sheets.append(current) 144 | 145 | inspector.widget.onRedo() 146 | assert inspector.widget.style_text_edit.toPlainText() == style_sheets[-1] 147 | 148 | 149 | @pytest.fixture 150 | def initial_qss(): 151 | return """\ 152 | * { 153 | margin: 0px; 154 | padding: 0px; 155 | border: 0px; 156 | font-family: "Century Gothic"; 157 | } 158 | """ 159 | 160 | 161 | @pytest.fixture 162 | def inspector(qtbot, initial_qss): 163 | """ 164 | :type qtbot: pytestqt.plugin.QtBot 165 | """ 166 | qApp.setStyleSheet(initial_qss) 167 | 168 | inspector_ = StyleSheetInspector() 169 | qtbot.addWidget(inspector_) 170 | return inspector_ 171 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py35, py36, flake8 3 | 4 | [testenv:flake8] 5 | basepython=python 6 | deps=flake8 7 | commands=flake8 qt_style_sheet_inspector 8 | 9 | [testenv] 10 | passenv=DISPLAY XAUTHORITY 11 | deps = 12 | -r{toxinidir}/requirements_dev.txt 13 | commands = 14 | pytest tests 15 | -------------------------------------------------------------------------------- /travis_pypi_setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """Update encrypted deploy password in Travis config file 4 | """ 5 | 6 | 7 | from __future__ import print_function 8 | 9 | import base64 10 | import json 11 | import os 12 | from getpass import getpass 13 | 14 | import yaml 15 | 16 | from cryptography.hazmat.backends import default_backend 17 | from cryptography.hazmat.primitives.asymmetric.padding import PKCS1v15 18 | from cryptography.hazmat.primitives.serialization import load_pem_public_key 19 | 20 | try: 21 | from urllib import urlopen 22 | except: 23 | from urllib.request import urlopen 24 | 25 | 26 | GITHUB_REPO = 'fogo/qt_style_sheet_inspector' 27 | TRAVIS_CONFIG_FILE = os.path.join( 28 | os.path.dirname(os.path.abspath(__file__)), '.travis.yml') 29 | 30 | 31 | def load_key(pubkey): 32 | """Load public RSA key, with work-around for keys using 33 | incorrect header/footer format. 34 | 35 | Read more about RSA encryption with cryptography: 36 | https://cryptography.io/latest/hazmat/primitives/asymmetric/rsa/ 37 | """ 38 | try: 39 | return load_pem_public_key(pubkey.encode(), default_backend()) 40 | except ValueError: 41 | # workaround for https://github.com/travis-ci/travis-api/issues/196 42 | pubkey = pubkey.replace('BEGIN RSA', 'BEGIN').replace('END RSA', 'END') 43 | return load_pem_public_key(pubkey.encode(), default_backend()) 44 | 45 | 46 | def encrypt(pubkey, password): 47 | """Encrypt password using given RSA public key and encode it with base64. 48 | 49 | The encrypted password can only be decrypted by someone with the 50 | private key (in this case, only Travis). 51 | """ 52 | key = load_key(pubkey) 53 | encrypted_password = key.encrypt(password, PKCS1v15()) 54 | return base64.b64encode(encrypted_password) 55 | 56 | 57 | def fetch_public_key(repo): 58 | """Download RSA public key Travis will use for this repo. 59 | 60 | Travis API docs: http://docs.travis-ci.com/api/#repository-keys 61 | """ 62 | keyurl = 'https://api.travis-ci.org/repos/{0}/key'.format(repo) 63 | data = json.loads(urlopen(keyurl).read().decode()) 64 | if 'key' not in data: 65 | errmsg = "Could not find public key for repo: {}.\n".format(repo) 66 | errmsg += "Have you already added your GitHub repo to Travis?" 67 | raise ValueError(errmsg) 68 | return data['key'] 69 | 70 | 71 | def prepend_line(filepath, line): 72 | """Rewrite a file adding a line to its beginning. 73 | """ 74 | with open(filepath) as f: 75 | lines = f.readlines() 76 | 77 | lines.insert(0, line) 78 | 79 | with open(filepath, 'w') as f: 80 | f.writelines(lines) 81 | 82 | 83 | def load_yaml_config(filepath): 84 | with open(filepath) as f: 85 | return yaml.load(f) 86 | 87 | 88 | def save_yaml_config(filepath, config): 89 | with open(filepath, 'w') as f: 90 | yaml.dump(config, f, default_flow_style=False) 91 | 92 | 93 | def update_travis_deploy_password(encrypted_password): 94 | """Update the deploy section of the .travis.yml file 95 | to use the given encrypted password. 96 | """ 97 | config = load_yaml_config(TRAVIS_CONFIG_FILE) 98 | 99 | config['deploy']['password'] = dict(secure=encrypted_password) 100 | 101 | save_yaml_config(TRAVIS_CONFIG_FILE, config) 102 | 103 | line = ('# This file was autogenerated and will overwrite' 104 | ' each time you run travis_pypi_setup.py\n') 105 | prepend_line(TRAVIS_CONFIG_FILE, line) 106 | 107 | 108 | def main(args): 109 | public_key = fetch_public_key(args.repo) 110 | password = args.password or getpass('PyPI password: ') 111 | update_travis_deploy_password(encrypt(public_key, password.encode())) 112 | print("Wrote encrypted password to .travis.yml -- you're ready to deploy") 113 | 114 | 115 | if '__main__' == __name__: 116 | import argparse 117 | parser = argparse.ArgumentParser(description=__doc__) 118 | parser.add_argument('--repo', default=GITHUB_REPO, 119 | help='GitHub repo (default: %s)' % GITHUB_REPO) 120 | parser.add_argument('--password', 121 | help='PyPI password (will prompt if not provided)') 122 | 123 | args = parser.parse_args() 124 | main(args) 125 | --------------------------------------------------------------------------------