python-3.4, pyqt5: somthing similar like loadUiType for the resource file?

1.1k views Asked by At

I was wondering if there might be something similar to loadUiType for the resource file. Of course one can use pyrcc5 example.qrc -o example_rc.py but than I have to do this step every time something is changed. Using:

from PyQt5.uic import loadUiType
Ui_MainWindow, QMainwindo = loadUiType('~/example.ui')

renders the usage of the pyuic5-step unnecessary, which eases the application building process a bit.

How would one do that with the resource file?

cheers, Christian

1

There are 1 answers

1
ekhumoro On BEST ANSWER

At one time, both pyuic and pyrcc were pure commandline tools written in C++. But the pyuic tool was ported to python for PyQt4 (I think as a student project by Thorsten Marek), and now has a separate uic module of it's own.

I don't think anyone has ever suggested porting pyrcc to python. A brief skim of the code (it's quite short), suggests this might be feasible, but it probably wouldn't be straightforward.

As stated in the comments, there is a QResource class that allows resources to be registered at runtime. But it still requires pre-compilation using the external rcc tool. Since PyQt generally follows the Qt APIs quite closely, this probably explains why it also doesn't have a way to directly compile and load resources at runtime.