Where is PyQT looking for resource files?

I use QT Designer to create user interface forms that include bitmaps. Images are saved as resource files and processed using the pyrcc4 file into type files img_rc.py. Forms are compiled at runtime loadUiType(). The question is where can I put resource files? The documentation says to put them in the file folder .ui, but if I do, I will get

ImportError: No module named img_rc

On the other hand, if I put image_rc.pyin the current working directory from which I am running the python script, then it loads correctly. In fact, I can delete the file .pyand leave only the bytecode file in the working directory image_rc.pyc, and it still works.

The ui forms are intended to be used as a package in many different applications. Saving resource files in a working directory, not in a package, makes no sense. The argument from_importsays it affects how it is imported, but I could not do anything but return ValueError: Empty module name. What am I doing wrong?

+4
source share

Source: https://habr.com/ru/post/1544335/


All Articles