<div dir="ltr">Hi<div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, May 6, 2014 at 9:01 AM, Tim Sutton <span dir="ltr"><<a href="mailto:lists@linfiniti.com" target="_blank">lists@linfiniti.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi<div class="gmail_extra"><br><br><div class="gmail_quote"><div class="">On Tue, May 6, 2014 at 8:54 AM, Nathan Woodrow <span dir="ltr"><<a href="mailto:madmanwoo@gmail.com" target="_blank">madmanwoo@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I normally do it this way:<div><br></div><div>


base, widget = uic.<span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">loadUiType('myui.ui')</span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px"><br>



</span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">class MyWidget(base, widget):</span></div><div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">    def __init__(self, parent=None)</span></div>




<div><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">         super(MyWidget, self).__init__(parent)</span></div></div></blockquote><div><br></div></div><div>According to the docs[1] you get the concrete class first, then the base class in the returned tuple:</div>


<div><br></div><div><dl><dt style="color:rgb(0,0,0);font-family:'Times New Roman';font-size:12px"><tt style="background-color:transparent;padding:0px 1px;font-size:0.95em">PyQt4.uic.</tt><tt style="background-color:transparent;padding:0px 1px;font-size:1.2em;font-weight:bold">loadUiType</tt><big>(</big><em>uifile</em><span style="font-size:1.3em">[</span>, <em>from_imports=False</em><span style="font-size:1.3em">[</span>, <em>resource_suffix='_rc'</em><span style="font-size:1.3em">]</span><span style="font-size:1.3em">]</span><big>)</big><a href="http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#PyQt4.uic.loadUiType" title="Permalink to this definition" style="color:white;text-decoration:none;font-size:0.8em;padding:0px 4px" target="_blank"></a></dt>


<dd style="margin-top:3px;margin-bottom:10px;margin-left:30px;text-align:justify;line-height:15.600000381469727px;color:rgb(0,0,0);font-family:'Times New Roman';font-size:12px"><p style="margin-top:0px">Load a Qt Designer <tt style="background-color:rgb(236,240,243);padding:0px 1px;font-size:0.95em"><span>.ui</span></tt> file and return a tuple of the generated <em>form class</em> and the <em>Qt base class</em>. These can then be used to create any number of instances of the user interface without having to parse the <tt style="background-color:rgb(236,240,243);padding:0px 1px;font-size:0.95em"><span>.ui</span></tt> file more than once.</p>


</dd></dl></div><div><br></div><div>[1] <a href="http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#the-uic-module" target="_blank">http://pyqt.sourceforge.net/Docs/PyQt4/designer.html#the-uic-module</a></div><div><br>

</div><div>Regards</div><span class="HOEnZb"><font color="#888888">
<div><br></div></font></span></div></div></div></blockquote><div><br></div><div>Ah did you mean that you save a line of code by using super?</div><div><br></div><div>Regards</div><div><br></div><div>Tim</div><div> </div>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="HOEnZb"><font color="#888888"><div></div>

<div>Tim</div></font></span><div><div class="h5"><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div dir="ltr">
<span><font color="#888888"><div><br></div><div>- Nathan</div></font></span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">

On Tue, May 6, 2014 at 4:52 PM, Tim Sutton <span dir="ltr"><<a href="mailto:lists@linfiniti.com" target="_blank">lists@linfiniti.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">




<div dir="ltr">Hi<div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Sat, Apr 26, 2014 at 2:45 PM, Anita Graser <span dir="ltr"><<a href="mailto:anitagraser@gmx.at" target="_blank">anitagraser@gmx.at</a>></span> wrote:<br>






<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
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.<br>
<br>
from PyQt4 import uic<br>
self.dock = uic.loadUi( os.path.join( path, "dockwidget2.ui" ) )<br>
<br></blockquote><div><br></div></div><div>As Martin mentioned, getting the class type back is nicer. I tested this and it works nicely:</div><div><br></div><div><br></div><div>----------------</div><div><br></div><div><div>




import os</div>

<div><br></div><div>from PyQt4 import QtCore, QtGui, uic</div><div><br></div><div>BASE_CLASS = uic.loadUiType(os.path.join(</div><div>    os.path.dirname(__file__), 'results_dialog_base.ui'))[0]</div><div><br></div>






<div><br></div><div>class ResultDialog(QtGui.QDialog, BASE_CLASS):</div><div>    """Dialog for showing the results of the plugin creation process."""</div><div>    def __init__(self):</div><div>






        QtGui.QDialog.__init__(self)</div><div>        # Set up the user interface from Designer.</div><div>        self.setupUi(self)</div></div><div><br></div><div>--------------</div><div><br></div><div>The advantage is that you can use Qt multi-inheritance which means less and cleaner code. More details in the Qt section at [1].</div>






<div><br></div><div>[1] <a href="http://test.inasafe.org/en/developer-docs/coding_standards.html" target="_blank">http://test.inasafe.org/en/developer-docs/coding_standards.html</a><br></div><div><br></div><div>Regards</div>




<span><font color="#888888"><div><br></div>

<div>Tim</div></font></span><div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">





Thanks for any insights!<br>
<br>
Best wishes,<br>
Anita<span><font color="#888888"><br>
<br>
<br>
<br>
-- <br>
<a href="http://anitagraser.com" target="_blank">anitagraser.com</a><br>
______________________________<u></u>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a><br>
</font></span></blockquote></div></div><br><br clear="all"><div><div><br></div>-- <br><div dir="ltr">Tim Sutton - QGIS Project Steering Committee Member<br>==============================================<br>Please do not email me off-list with technical<br>






support questions. Using the lists will gain<br>more exposure for your issues and the knowledge<br>surrounding your issue will be shared with all.<br><br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>






==============================================</div>
</div></div></div>
<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br></blockquote></div><br></div>
</div></div></blockquote></div></div></div><div><div class="h5"><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Tim Sutton - QGIS Project Steering Committee Member<br>==============================================<br>

Please do not email me off-list with technical<br>
support questions. Using the lists will gain<br>more exposure for your issues and the knowledge<br>surrounding your issue will be shared with all.<br><br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>


==============================================</div>
</div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Tim Sutton - QGIS Project Steering Committee Member<br>==============================================<br>Please do not email me off-list with technical<br>

support questions. Using the lists will gain<br>more exposure for your issues and the knowledge<br>surrounding your issue will be shared with all.<br><br>Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>

==============================================</div>
</div></div>