[PyQt] pyuic4 vs uic.loadUI

fpp fpp.gsp at gmail.com
Tue Sep 28 20:46:48 BST 2010


On Tue, Sep 28, 2010 at 6:19 PM, pard <pardmeister at gmail.com> wrote:
> Hi
> I have found that some people use pyuic4 to compile their ui files and some
> load them dynamically using loadUI.
> Does anyone have the pro's and con's of each of these methods? What is the
> recommended PyQT way of doing this?

Thanks for starting the discussion, I've often wondered myself. I have
no opinion one way or another, but since most seem to favour loadUI,
I'll play the devil's advocate for pyuic4 :-)

I can think of several reasons to prefer compiled ui files :

1) if you're using eric4 as an IDE, it does everything for you, so why not ?

2) on a reasonably recent PC, and for common UIs, the additional
launch time, CPU & memory usage due to loadUI are probably not even
measurable, compared to the Python, Qt and PyQt startup load.
For extremely complex and widget-heavy UIs this might be less evident
: parsing XML is not the most efficient thing in the world after all.
And if we're running on mobile platforms with more limited
power/CPU/RAM and slow Flash I/O, like Nokia's Symbian or Maemo
smartphones, it could become quite perceptible.

3) during the early design phases, it's sometimes handy to be able to
manually modify a generated Python UI file, just to check out the
effect of some minor change, without having to do it in Designer
(especially if it involves sizers :-)

4) if for some reason you wish or need to distribute only binaries, as
sometimes happens, you can exclude the .ui source files and ship only
the UI .pyc/pyo files.
Dumb, yes, but not entirely impossible :-)


More information about the PyQt mailing list