[PyQt] pyuic vs. uic.loadUi()?

Dave Fancella dave at davefancella.com
Fri Jun 15 16:50:28 BST 2007


On Friday 15 June 2007 10:34 am, Dirk Reiners wrote:
> 	Hi Everybody,
>
> as I said already I'm just starting out using PyQt and therefore I would
> like to tap into the experience pool on the list to avoid making
> fundamental mistakes early in the project that are hard to fix later.
>
> I'm trying to decide whether to a) use pyuic4 to generate a python module
> to include, or b) use uic.loadUi() to load the .ui file directly.
>
> snip
>
> Is there something more that I'm missing?

Yes.  You'll get a tuple out of this, where the first part of the tuple is a 
type object.  You can use that type object to inherit the class.

myType, whatever = uic.loadUi('path/to/some/file.ui')

class MyType(QtGui.QButton, myType):

see what I mean?  My only issue is that it does make importing the module take 
some extra time, and if you use wrappers around the os.path module to find 
your ui files (recommended, since they'll be in different locations depending 
on how the program was installed) then you have to have that module imported 
and initialized before you start importing your ui, so startup time can be 
increased quite a bit.  Otherwise, it's really nice to be able to change the 
ui files and just rerun the program to see the changes.  :)

Dave

> Thanks
>
> 	Dirk
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list