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

Phil Thompson phil at riverbankcomputing.com
Wed May 20 09:25:44 BST 2009

On Tue, 19 May 2009 15:36:45 -0700, Brent Villalobos
<Brent.Villalobos at pdi.dreamworks.com> wrote:
> Let me rephrase this.  Is there a way to tell pyuic4 and/or the 
> PyQt4.uic module that my resource modules are in a different python 
> package?  Or am I out of luck since the resource path was created by 
> designer?  Are there any plans for pyuic4 to support resource files that 
> are in a different python package?
> -Brent
> Brent Villalobos wrote:
>> 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

No plans - patches welcome.


More information about the PyQt mailing list