[Qgis-developer] remove action using Python

Bernhard Ströbl bernhard.stroebl at jena.de
Tue Jan 22 23:38:45 PST 2013


Dear all,
in a plugin I add a Python action to a layer with this:

myLayer.actions().addAction(1, myActionName, myPythonCode)

upon unloading the plugin I would like to remove the action from the 
layer (because some of the code needed is in the plugin) but I did not 
find a method to do so.

I could
1) loop through all actions and store them in an array (except the one I 
want to remove
2) use clearActions() method
3) loop through the array and use
addAction(thisAction.type(), thisAction.name(), thisAction.action())
to reestablish all other actions

any better solutions for this?

Bernhard


More information about the Qgis-developer mailing list