<div dir="auto">Hi Salvatore, so I will try to extend your python macro for selecting records through relationship with the code of Andrea Borruso!!! <div dir="auto"><br></div><div dir="auto">Regards</div><div dir="auto">Luca</div></div><div class="gmail_extra"><br><div class="gmail_quote">Il 16 apr 2017 9:58 PM, "Salvatore Larosa" <<a href="mailto:lrssvtml@gmail.com">lrssvtml@gmail.com</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Luca,<br>
<br>
On Fri, Apr 14, 2017 at 10:31 PM, Luca Mandolesi <<a href="mailto:mandoluca@gmail.com">mandoluca@gmail.com</a>> wrote:<br>
> Hi,<br>
> I would to know if it's possibile to add a python action into a layer<br>
> charged inside layer registry? There is a method inside pyQgis API?<br>
<br>
sure, it is possible. With 2.x version the below example should be working:<br>
<br>
>>> vl = iface.activeLayer()<br>
>>> actions = vl.actions()<br>
>>><br>
>>> actionName = 'Show feature id'<br>
>>> actionContent = 'from qgis.utils import iface; iface.messageBar().<wbr>pushMessage("Feature ID: [% $id %]", 0)'<br>
>>><br>
>>> actions.addAction(QgsAction.<wbr>GenericPython, actionName, actionContent)<br>
<br>
Since QGIS 3 the code for actions was revamped, please see<br>
<a href="https://goo.gl/rGgYHC" rel="noreferrer" target="_blank">https://goo.gl/rGgYHC</a>.<br>
<br>
Ciao,<br>
-SL<br>
<br>
<br>
--<br>
Salvatore Larosa<br>
linkedIn: <a href="http://linkedin.com/in/larosasalvatore" rel="noreferrer" target="_blank">http://linkedin.com/in/<wbr>larosasalvatore</a><br>
twitter: @lrssvt<br>
skype: s.larosa<br>
IRC: lrssvt on freenode<br>
</blockquote></div></div>