[PyQt] pyuic resources import

Sebastian Elsner sebastianelsner at freenet.de
Wed Jul 4 12:15:16 BST 2012


Hello,

my folder structure for an application I want to restructure is like this:

src
    lib
       ui
          __init__.py
          MainWindow
             __init__.py
             MainWindow.ui
             MainWindow.py
             ui_MainWindow.py
          resources.qrc
          resources_rc.py
    main.py

The MainWindow.ui uses icons from the resources.qrc (which I would also 
like to use for all other dialogs as well) and this works perfectly. 
pyuic translates the .ui file to ui_MainWindow.py and adds an "import 
resources_rc" This is where it stops working because in the MainWindow 
folder is no resources_rc file and thus the import fails.

Ways to avoid this, which I thought about:
* tell pyuic not to import resources_rc and import it manually in main.py
* split the resources.qrc for icons only used in MainWindow.ui and put 
icons used in other dialogs in another qrc -> only what about icons used 
in MainWindow and another dialog and thus defined two qrcs. does the 
system use double the memory?
* make pyuic aware of absolute imports like import lib.ui.resources_rc

What is the recommended way of doing this?

Cheers

Sebastian




More information about the PyQt mailing list