[Qgis-user] Trigger action from pyqgis

Didac Busquets didac.busquets at immense.ai
Wed Apr 24 04:30:49 PDT 2024


Hello,


In QGis I have defined a set of actions for a layer. I can trigger the actions by selecting the Actions icon in the toolbar, select the appropriate action, and then I get a cross mouse icon and can start clicking on features to actually run the action.

However, I'd like to start the process (i.e. get the "cross" icon) from PyQgis. I've looked at the QgsAction documentation, and it has a run method, but this is to apply it to a given feature. How can I run/start/trigger the action from python so that I can then start clicking on all the features I want the action to be applied to?


The use case is the following: I want to update field X of several features in my layer to a new value. I've designed a docked widget so that I can input the new value to use, and then I want to start clicking on the features that I want to update; then change the value and click on other features, and so on.

The action creation form (image attached) mentions that the action could be triggered from a button widget, but I'm not clear if that means I already need to know what feature I want it to apply to (which is not the case).

Any help will be appreciated.

Regards,

Didac




[https://immense.ai/email/immense.jpg]<https://immense.ai>



[Twitter]<https://twitter.com/immense_ai>  [Facebook] <https://www.facebook.com/ImmenseSimulations/>   [LinkedIn] <https://www.linkedin.com/company/immense-simulations-ltd/>



[https://immense.ai/email/spacer.gif]   [https://immense.ai/email/spacer.gif]
Didac Busquets, PhD | Chief Scientist and co-founder
didac.busquets at immense.ai<mailto:didac.busquets at immense.ai>



Sign up to our newsletter here<https://immense.us16.list-manage.com/subscribe?u=bd57eabb3c96301a8f113cbbd&id=c92fc09b7a>
www.immense.ai<https://www.immense.ai>



[https://immense.ai/email/spacer.gif]



Personal data: emails, by default, contain basic personal data and are not necessarily secure. If, in answering this email, you provide additional personal information, we will process that information for the purposes for which you have supplied it and as set out in our Privacy Policy<https://immense.ai/privacy-policy/>, which also contains information about your rights.

This communication, and the information it contains, is (a) intended for the person(s) and/or organisation(s) to whom it is addressed and is for no other person(s) or organisation(s) and (b) may be confidential, legally privileged and protected by law, including law of copyright. Unauthorised use, copying, forwarding or disclosure of any of it may be unlawful. If you have received this communication in error, please contact us immediately at privacy at immense.ai<mailto:privacy at immense.ai>.

Immense Simulations Barcelona SL, ES B67427807, C/Corsega, 299, 6e, 08008 Barcelona, Spain is a subsidiary of Immense Simulations Limited, a limited company registered in England and Wales with registered number 09782647,
and registered address at International House, 36-38 Cornhill, London, England, EC3V 3NG..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20240424/e73be496/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: action.png
Type: image/png
Size: 78503 bytes
Desc: action.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20240424/e73be496/attachment-0001.png>


More information about the QGIS-User mailing list