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

Nathan Woodrow madmanwoo at gmail.com
Mon May 5 23:54:52 PDT 2014


I normally do it this way:

base, widget = uic.loadUiType('myui.ui')

class MyWidget(base, widget):
    def __init__(self, parent=None)
         super(MyWidget, self).__init__(parent)

- Nathan


On Tue, May 6, 2014 at 4:52 PM, Tim Sutton <lists at linfiniti.com> wrote:

> Hi
>
>
> 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):
>         QtGui.QDialog.__init__(self)
>         # Set up the user interface from Designer.
>         self.setupUi(self)
>
> --------------
>
> 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
>
> Regards
>
> Tim
>
>
>
>
>> 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
> ==============================================
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140506/3a3c90d7/attachment.html>


More information about the Qgis-developer mailing list