[Qgis-developer] Basic question: How to select a layer in the GUI and get the handle in the Python code?

bernhard.stroebl at jena.de bernhard.stroebl at jena.de
Wed Dec 7 08:59:02 EST 2011


Hi,

have a look at the code in fTools. Most Uis have comboBoxes for layer 
selection and in fTools_utils there is code to get the layer object 
corresponding to a layer name.

regards

Bernhard

Am 07.12.2011 14:28, schrieb Ole Nielsen:
> Hi Alexander and mailing list
>
> Thanks for the quick reply - it is great to have the support of this
> community.
>
> If I understand you correctly, you want to access current selected layer,
>> right?
>> Use self.iface.mapCanvas().currentLayer() for this
>>
>
> Sorry, I was perhaps not as clear as I could have been. I have already
> written plugins using the currentLayer option. What I need now is to
> combine two layers for a specific analysis. So I imagine being able to
> select them through the plugin GUI selection combos and return the two
> layer handles to the Python code in the same format as what is provided by
> current layer. However, I have no idea how to start doing this.
>
>
>>> Also, is there such a thing as a reference manual for the python plugin
>> API?
>> Python API mainly the same as C++ API, so you can use C++ API from [0]
>>
> OK
>
>
>> Also there is PyQGIS Developer Cookbook [1] where you can find some code
>> examples
>>
> Yes - I already read that and found it very helpful. However, nowhere to be
> seen are explanations of the fundamentals of selecting layers through the
> plugin and working with them.
>
> Your help is much appreciated
> Cheers
> Ole
>
>


________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Server.
http://www.nod32.com


More information about the Qgis-developer mailing list