Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. qss url() not working on Python 3.9
Forum Updated to NodeBB v4.3 + New Features

qss url() not working on Python 3.9

Scheduled Pinned Locked Moved Solved Qt for Python
8 Posts 4 Posters 991 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nutrx
    wrote on last edited by nutrx
    #1

    Hey,
    just to make sure it's not me: the following code runs properly with both PySid2 and PySide6 on Python3.8 on my machine (Windows 10), i.e. when checking the checkbox I can see the indicator from the svg

    from PySide6.QtCore import QDir
    from PySide6.QtWidgets import QApplication, QMainWindow, QCheckBox
    import sys
    import os
    
    
    class MainWindow(QMainWindow):
        def __init__(self):
            super().__init__()
            self.setCentralWidget(QCheckBox('test'))
    
    
    if __name__ == '__main__':
        app = QApplication(sys.argv)
    
        # the icon used below lies in the same dir as this file
        QDir.addSearchPath('icon', os.path.abspath(os.path.dirname(__file__)))
    
        app.setStyleSheet("""
    QCheckBox::indicator:checked {
        image: url(icon:/checkbox_checked.svg);
    }
        """)
        mw = MainWindow()
        mw.show()
        sys.exit(app.exec_())
    

    When I run it on Python3.9, there's no indicator, the whole thing just disappears. This applies to all qss url()s and both PySide2 and PySide6. Is this a bug?
    Thanks!

    Versions for both Python 3.8 and 3.9:

    • PySide2 5.15.2
    • PySide6 6.0.1

    edit also doesnt work with absolute paths, also not with strings in the url() which all seems to work on Python 3.8

    eyllanescE 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you try the same path without the leading slash with Python 3.9 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you try the same path without the leading slash with Python 3.9 ?

        N Offline
        N Offline
        nutrx
        wrote on last edited by
        #3

        @SGaist Hi, yes same result

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Ok, can you also give the exact versions of Python ?
          And how did you install PySide ? Pip or conda ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          0
          • SGaistS SGaist

            Ok, can you also give the exact versions of Python ?
            And how did you install PySide ? Pip or conda ?

            N Offline
            N Offline
            nutrx
            wrote on last edited by
            #5

            jep, Python 3.8.7 and 3.9.3 and installation via pip

            1 Reply Last reply
            0
            • GilgameshG Offline
              GilgameshG Offline
              Gilgamesh
              wrote on last edited by
              #6

              Quizás ese widget no acepta ese estilo

              1 Reply Last reply
              0
              • N nutrx

                Hey,
                just to make sure it's not me: the following code runs properly with both PySid2 and PySide6 on Python3.8 on my machine (Windows 10), i.e. when checking the checkbox I can see the indicator from the svg

                from PySide6.QtCore import QDir
                from PySide6.QtWidgets import QApplication, QMainWindow, QCheckBox
                import sys
                import os
                
                
                class MainWindow(QMainWindow):
                    def __init__(self):
                        super().__init__()
                        self.setCentralWidget(QCheckBox('test'))
                
                
                if __name__ == '__main__':
                    app = QApplication(sys.argv)
                
                    # the icon used below lies in the same dir as this file
                    QDir.addSearchPath('icon', os.path.abspath(os.path.dirname(__file__)))
                
                    app.setStyleSheet("""
                QCheckBox::indicator:checked {
                    image: url(icon:/checkbox_checked.svg);
                }
                    """)
                    mw = MainWindow()
                    mw.show()
                    sys.exit(app.exec_())
                

                When I run it on Python3.9, there's no indicator, the whole thing just disappears. This applies to all qss url()s and both PySide2 and PySide6. Is this a bug?
                Thanks!

                Versions for both Python 3.8 and 3.9:

                • PySide2 5.15.2
                • PySide6 6.0.1

                edit also doesnt work with absolute paths, also not with strings in the url() which all seems to work on Python 3.8

                eyllanescE Offline
                eyllanescE Offline
                eyllanesc
                wrote on last edited by eyllanesc
                #7

                @nutrx It works for me, share the log when executing the script using the following command: QT_DEBUG_PLUGINS=1 python /path/of/your_script.py. If you use .png instead of .svg, do you still have that problem?

                If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                N 1 Reply Last reply
                0
                • eyllanescE eyllanesc

                  @nutrx It works for me, share the log when executing the script using the following command: QT_DEBUG_PLUGINS=1 python /path/of/your_script.py. If you use .png instead of .svg, do you still have that problem?

                  N Offline
                  N Offline
                  nutrx
                  wrote on last edited by nutrx
                  #8

                  @eyllanesc png works in both versions. with svg, using

                  set QT_DEBUG_PLUGINS=1
                  python3.9 my_file.py
                  

                  when checking the box it fails with "Cannot load library [...]\\Roaming\\Python\\Python39\\site-packages\\PySide6\\plugins\\imageformats\\qsvg.dll: Das angegebene Modul wurde nicht gefunden. [cannot find the module]" besides other similar errors (even though it exists). When I run it with Python3.8 it works.

                  However, I noticed that PySide2/6 (and weirdly I think also the Python 3.9 installation) was located in Roaming for Python 3.9 and that it seems to look in various places for packages and the paths for site-packages in Roaming differ from the paths in AppData/Local/Programs. Therefore, although there was only one global (PATH) Python 3.9 installed, I tried by removing the Roaming stuff and reinstalled Python 3.9 and the packages, and now it seems to work...

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved