Hi Giuseppe and Alexander<div><br></div><div>Thank you for the help - both of you. I followed your instructions and can now pick file names of loaded layers.</div><div><br></div><div>Also, as you suggested, I realised that I needed to study the Qt4 interface and have gone through most of the tutorials (<a href="http://zetcode.com/tutorials/pyqt4" target="_blank">http://zetcode.com/tutorials/pyqt4</a>)</div>

<div><br></div><div>The only things I had to change was </div><div><ul><li>that the layerCombo lives in &#39;dlg.ui&#39; and not &#39;self&#39; since I am using a skeleton generated by the plugin generator. Is that OK?</li>
<li>that the method in layerCombo to add layers is &#39;addItem&#39; and not &#39;append&#39; :-)</li></ul></div><div>With that loaded layer names show up in the combo and after selection the fully qualified filename is returned by layer.source()</div>
<div><br></div><div>However, if I want a handle to an active layer, like I got with self.iface.mapCanvas().currentLayer() is there any way that could be obtained from the layer object?</div><div><br></div><div><br></div><div>
Grateful for your advice.</div><div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Cheers and thanks</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">

Ole </p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><br></p></div><div><br></div><div><br><div class="gmail_quote">On Thu, Dec 8, 2011 at 7:46 PM, Giuseppe Sucameli <span dir="ltr">&lt;<a href="mailto:sucameli@faunalia.it" target="_blank">sucameli@faunalia.it</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ole,<br>
<div><br>
On Thu, Dec 8, 2011 at 3:54 AM, Ole Nielsen<br>
&lt;<a href="mailto:ole.moller.nielsen@gmail.com" target="_blank">ole.moller.nielsen@gmail.com</a>&gt; wrote:<br>
&gt; I am maybe looking for a file or layer selection combo and<br>
&gt; a hint on how to make it work.<br>
<br>
</div>First create a combo in your UI named &quot;layerCombo&quot;<br>
<br>
Then populate the combo running:<br>
<br>
self.layers = self.iface.legendInterface().layers()  # store the layer list<br>
self.layerCombo.clear()  # clear the combo<br>
for layer in self.layers:    # foreach layer in legend<br>
    self.layerCombo.append( <a href="http://layer.name" target="_blank">layer.name</a>() )    # add it to the combo<br>
<br>
<br>
When you have to get the layer selected in the combo,<br>
just us the following snippet:<br>
<br>
index = self.layerCombo.currentIndex()<br>
if index &lt; 0:<br>
    # it may occur if there&#39;s no layer in the combo/legend<br>
else:<br>
    layer = self.layers[ index ]    # get the layer by index from the<br>
previous stored list<br>
    source = layer.source()    # get the layer source<br>
<br>
<br>
I haven&#39;t tried the previous code, so it could contains errors.<br>
<div><br>
&gt; I have very limited experience with UIs so please forgive me my basic<br>
&gt; questions.<br>
<br>
</div>Look at QT tutorials, they contain everything you need<br>
to know about UI creation.<br>
<br>
Cheers.<br>
<div><div><br>
&gt;<br>
&gt; Cheers and thanks<br>
&gt; Ole<br>
&gt;<br>
&gt; On Wed, Dec 7, 2011 at 8:57 PM, Alexander Bruy &lt;<a href="mailto:alexander.bruy@gmail.com" target="_blank">alexander.bruy@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Ole,<br>
&gt;&gt;<br>
&gt;&gt; 2011/12/7 Ole Nielsen &lt;<a href="mailto:ole.moller.nielsen@gmail.com" target="_blank">ole.moller.nielsen@gmail.com</a>&gt;:<br>
&gt;&gt; &gt; Sorry, I was perhaps not as clear as I could have been. I have already<br>
&gt;&gt; &gt; written plugins using the currentLayer option. What I need now is to<br>
&gt;&gt; &gt; combine<br>
&gt;&gt; &gt; two layers for a specific analysis. So I imagine being able to select<br>
&gt;&gt; &gt; them<br>
&gt;&gt; &gt; through the plugin GUI selection combos and return the two layer handles<br>
&gt;&gt; &gt; to<br>
&gt;&gt; &gt; the Python code in the same format as what is provided by current layer.<br>
&gt;&gt; &gt; However, I have no idea how to start doing this.<br>
&gt;&gt;<br>
&gt;&gt; Ah, understand. That&#39;s not so difficult. You need to get layer name<br>
&gt;&gt; from combobox,<br>
&gt;&gt; then find layer by name. Here is small function that did this work for you<br>
&gt;&gt;<br>
&gt;&gt; def getVectorLayerByName( layerName ):<br>
&gt;&gt;  layerMap = QgsMapLayerRegistry.instance().mapLayers()<br>
&gt;&gt;  for name, layer in layerMap.iteritems():<br>
&gt;&gt;    if layer.type() == QgsMapLayer.VectorLayer and <a href="http://layer.name" target="_blank">layer.name</a>() ==<br>
&gt;&gt; layerName:<br>
&gt;&gt;      if layer.isValid():<br>
&gt;&gt;        return layer<br>
&gt;&gt;      else:<br>
&gt;&gt;        return None<br>
&gt;&gt;<br>
&gt;&gt; So in your code you can simply do something like this<br>
&gt;&gt;<br>
&gt;&gt; layerA = getVectorLayerByName( self.cmbLayerA.currentText() )<br>
&gt;&gt; layerB = getVectorLayerByName( self.cmbLayerB.currentText() )<br>
&gt;&gt;<br>
&gt;&gt; Hope this helps<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Alexander Bruy<br>
&gt;&gt; NextGIS<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Qgis-developer mailing list<br>
&gt; <a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
&gt; <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
&gt;<br>
<span><font color="#888888"><br>
<br>
<br>
--<br>
Giuseppe Sucameli<br>
</font></span></blockquote></div><br></div>