I have added an action on a layer(Layer_1) and assigned a shortcut on the keyboard to execute this action using 'Keyboard shortcut settings ..' from the toolbar, however, by pressing the number '2' which is the shortcut used by the user keyboard only activates the actions icon but the script associated with that action is not executed. To run it is necessary to click on any feature of the active layer.This is the script that must be executed:

from qgis.utils import iface
ly2 = QgsMapLayerRegistry.instance().mapLayersByName('Layer_2')[0]

Would it be possible to run this script without having to click on any feature of the active layer with that action?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.