[PyQt] Changing import statement in uic.loadUiType()

Brent Villalobos Brent.Villalobos at pdi.dreamworks.com
Tue May 19 23:03:27 BST 2009


I am laying out my gui using qt designer.  I'm using designer's resource 
manager to store icons.  Later, at run time, that ui file is fed into 
PyQt4.uic.loadUiType(file).  The problem is that the python code 
generated has this line:
"import icons_rc".

I have an icons_rc.py file that was generated using pyrcc4 and it is 
deployed alongside the ui file.  The problem is that icons_rc.py is in a 
different directory than the code calling uic.loadUiType() and so I get 
an import error.  I would really like to change "import icons_rc" to a 
fully qualified "import foo.bar.icons_rc" in order for the ui compiler 
to find it.  Is the only way for me to do this is to modify the file ui 
file before passing it to loadUiType()?  Or is there a cleverer way to 
do this that I'm not seeing?
-Brent


More information about the PyQt mailing list