Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-2191

pyside6-uic fails to correctly generate resource_rc location

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • 6.5.0
    • 6.4.1
    • PySide
    • None
    • My dev environment is on Ubuntu 22.04 using PyCharm as my IDE. Python 3.10.
    • Linux/Wayland
    • 97a7e7b2d (dev), 6e436003a (6.5), 814d66d55 (dev), 113f91229 (6.5), 313ad8c51 (dev), 55db7d9fc (6.5), f499612b6 (dev), 27e79dcd1 (6.5)

    Description

      I used QT Designer 6.4.1 to create a mainwindow.ui xml file.  From within QT Designer, I created a resource file named resources.qrc.

      Below is a representation of my project structure.  The ui file is located in:

      myfinancials/ui/ui_forms

      The resource qrc file is located in:

      myfinancials/resources

      The script to convert the ui and qrc files to py is located in:

      scripts (same level as myfinancials)

      .
      ├── myfinancials
      │   ├── common
      │   ├── data
      │   ├── myfinapp
      │   │   └── app.py
      │   ├── resources
      │   │   ├── icons
      │   │   │   └── logo-icon.png
      │   │   ├── images
      │   │   │   ├── login-logo.png
      ...
      │   │   └── resources.qrc
      │   └── ui
      │       ├── About.py
      │       ├── {}init{}.py
      │       ├── Maintenance.py
      │       ├── MainWindow.py
      │       ├── Password.py
      ...
      │       ├── ui_forms
      │       │   ├── mainwindow2.ui
      ...
      │       │   └── welcome.ui
      │       └── Welcome.py
      ...
      └── scripts
          └── pre-launch.sh

       

      Within the pre-launch.sh script, I run the following to create the resource_rc.py file, placing it in the resources directory.  The python ui file is placed in myfinancials/ui.

      pyside6-rcc ../myfinancials/resources/resources.qrc -o ../myfinancials/resources/resources_rc.py

      pyside6-uic ../myfinancials/ui/ui_forms/mainwindow2.ui --from-imports -o ../myfinancials/ui/MainWindow.py

      The resulting MainWindow.py file (with the --from-imports flag) creates an import statement:

      from  . import resources_rc

      Without the --from-imports flag, it is simply:

      import resources_rc

      Neither allow MainWindow.py to find the resource_rc.py in myfinancials/resources.  It is looking in myfinancials/ui which obviously doesn't have the resources_rc.py file to import.

      Altering the resources_rc.py generation to place the generated py file into myfinancials/ui to reside next to the MainWindow.py file resolves the import problem but it places the resource file in the wrong place according to my project structure.

      Within the ui file, it specifies the resources location as:

       <resources>
        <include location="../../resources/resources.qrc"/>
       </resources>

       

      The problem appears to be that pyside6-uic does not have a way to locate the generated resources_rc.py file to create the correct import statement.  Or pyside6-uic doesn't have an argument available to specify the location. Or I have done something "unnatural" in the world of Qt (sorry, I'm coming from GTK land).

      Attachments

        For Gerrit Dashboard: PYSIDE-2191
        # Subject Branch Project Status CR V

        Activity

          People

            crmaurei Cristian Maureira-Fredes
            j_brown Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: