Details
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).