[PyQt] pyuic4 vs uic Module

Christopher Probst christop.probst at gmail.com
Thu Aug 2 20:04:59 BST 2018


Thank-you very much for your insight. I must say, coming from the Qt C++
world, dynamically loading the ui at run-time seems unusual to me. Is there
a performance hit? Why not use pyqt4uic to compile in the code into Python?
What is the issue with that?

On Wed, 1 Aug 2018 at 17:24, Kyle Altendorf <sda at fstab.net> wrote:

>
>
> On August 1, 2018 5:08:48 PM EDT, Christopher Probst <
> christop.probst at gmail.com> wrote:
> >Helllo everybody,
> >
> >Is there any best practice suggestion as to how to interact with the Qt
> >ui
> >files? Is it better to load them dynamically using the uic module with
> >the
> >load uic.loadUi method?
> >
> >Or is it recommended to compile the ui files into python code using
> >pyuic4?
>
> I'm not sure any caveats between 4 vs 5 but I much prefer loading at run
> time.  Here's what I'm tending towards now.
>
>
> https://github.com/altendky/basicpyqt5example/blob/e08e75d16819fddc0514c513f43fa5148e59722c/src/basicpyqt5example/mainwindow.py#L37
>
> Ui, UiBase = PyQt5.uic.loadUiType(
>     pathlib.Path(__file__).parents[0] / 'mainwindow.ui',
> )
>
> class MainWindow(UiBase):
>     def __init__(self, parent=None):
>         super().__init__(parent) self.ui = Ui()
>         self.ui.setupUi(self)
>
> The one caveat that I'm aware of is the lack of a .py file for an IDE to
> parse for help completing names.  I'll note that there is a call in uic for
> compiling without having to run pyuic from the command line so some hybrid
> might make sense.
>
> Cheers,
> -kyle
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180802/fe4d1b8e/attachment.html>


More information about the PyQt mailing list