ColinDuquesnoy / QDarkStyleSheet

A dark style sheet for QtWidgets application
Other
2.76k stars 725 forks source link

Dark theme in version 3.2.1 is not working #339

Open skp17 opened 7 months ago

skp17 commented 7 months ago

Describe Your Environment

Language

Python

Description / Steps to Reproduce [if necessary]

Simply running the command $ qdarkstyle.example --palette=dark produces an error. Everything works fine with QDarkStyle v3.1. However, I'm getting problems with v3.2 & v3.2.1.

Actual Result

Traceback (most recent call last):
  File "c:\users\steven\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\steven\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\steven\.virtualenvs\nep_generic_db_tool-OeiXJOWV\Scripts\qdarkstyle.example.exe\__main__.py", line 7, in <module>
  File "C:\Users\steven\.virtualenvs\nep_generic_db_tool-OeiXJOWV\lib\site-packages\qdarkstyle\example\__main__.py", line 111, in main
    from qtpy import API_NAME, QT_VERSION, PYQT_VERSION, PYSIDE_VERSION, uic
  File "C:\Users\steven\.virtualenvs\nep_generic_db_tool-OeiXJOWV\lib\site-packages\qtpy\__init__.py", line 287, in <module>
    raise QtBindingsNotFoundError from None
qtpy.QtBindingsNotFoundError: No Qt bindings could be found

Expected Results / Proposed Result

[A description, output ou image of the expected/proposed result]

Relevant Code [if necessary]

$ qdarkstyle.example --palette=dark
ccordoba12 commented 7 months ago

Hey @skp17, thanks for reporting. We've also noticed a similar problem in Spyder.

@dpizetta, a simple way to reproduce this is by running the following commands in a virtualenv:

pip install pyqt==5.12 ipython
ipython

and then

In [1]: from qdarkstyle import load_stylesheet

In [2]: css = load_stylesheet()
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[2], line 1
----> 1 css = load_stylesheet()

File ~/.virtualenvs/test-qdark/lib/python3.8/site-packages/qdarkstyle/__init__.py:341, in load_stylesheet(*args, **kwargs)
    339 # No arguments
    340 if not kwargs and not args:
--> 341     stylesheet = _load_stylesheet(qt_api='pyqt5')
    343 # Old API arguments
    344 elif 'pyside' in kwargs or isinstance(arg, bool):

File ~/.virtualenvs/test-qdark/lib/python3.8/site-packages/qdarkstyle/__init__.py:273, in _load_stylesheet(qt_api, palette)
    271     stylesheet = ""
    272     # Todo: check this raise type and add to docs
--> 273     raise FileNotFoundError("Unable to find QSS file '{}' "
    274                             "in resources.".format(qss_rc_path))
    276 _logger.debug("Checking patches for being applied.")
    278 # Todo: check execution order for these functions
    279 # 1. Apply OS specific patches

FileNotFoundError: Unable to find QSS file ':qdarkstyle/dark/darkstyle.qss' in resources.

This error doesn't happen in PyQt 5.15, but it does in version 5.12 and, according to the info reported by @skp17, in 5.11 as well.

So, I think the assets need to be regenerated so that they work in older PyQt versions.

Could you take a look at that? Thanks!

dpizetta commented 7 months ago

Hey guys, thank you for reporting, I'll take a look this weekend. I think I generated the assets with pyside6, so maybe thats the problem. Thanks!

dpizetta commented 7 months ago

Actually, this is a problem with the QtPy already mentioned some time ago in this.

Since I'm building the assets in the Qt6, QtPy will try in this order PyQt5/PySide2/PyQt6/Pyside6. So, if it start with PySide6, QtPy won't test the other possibilities.

For now I'll rebuild the assets in Qt5, them with some time I can help with the PR for the QtPy.