[Qgis-developer] Is there an advantage in using pyuic on command line instead of uic.loadUi in plugin source?

Tim Sutton lists at linfiniti.com
Mon May 5 23:52:29 PDT 2014


On Sat, Apr 26, 2014 at 2:45 PM, Anita Graser <anitagraser at gmx.at> wrote:

> Hi,
> I'm wondering if there is an advantage in using pyuic to manually compile
> .ui files instead of just using uic.loadUi() in the plugin directly, e.g.
> from PyQt4 import uic
> self.dock = uic.loadUi( os.path.join( path, "dockwidget2.ui" ) )
As Martin mentioned, getting the class type back is nicer. I tested this
and it works nicely:


import os

from PyQt4 import QtCore, QtGui, uic

BASE_CLASS = uic.loadUiType(os.path.join(
    os.path.dirname(__file__), 'results_dialog_base.ui'))[0]

class ResultDialog(QtGui.QDialog, BASE_CLASS):
    """Dialog for showing the results of the plugin creation process."""
    def __init__(self):
        # Set up the user interface from Designer.


The advantage is that you can use Qt multi-inheritance which means less and
cleaner code. More details in the Qt section at [1].

[1] http://test.inasafe.org/en/developer-docs/coding_standards.html



> Thanks for any insights!
> Best wishes,
> Anita
> --
> anitagraser.com
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer

Tim Sutton - QGIS Project Steering Committee Member
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Irc: timlinux on #qgis at freenode.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140506/33f9c941/attachment-0001.html>

More information about the Qgis-developer mailing list