I am using QGIS3.4 (built-in Python 3) actions.addAction and trying to open a local photo, with the below code I am able to store the photo path in the feature attribute and created an action, I have also ticked the box "auto open form" in identify results tool

actions.addAction(QgsAction.OpenUrl,"Photos",'[% "photo" %]')

I verified the action has been created successfully:

enter image description here

The problem is when I click on the feature using identifier tool, the popped up window is not the photo, instead showing the photo below (I have also tried to add "file:///" in front of the path attribute, and still got same issue)

enter image description here

Then I also tested other type of actions (this is related to my second question below) such as GenericPython to see if it works using below line, again when I clicked the feature, nothing happened:

actions.addAction(QgsAction.GenericPython,"Test Action","print(1)")

I am not sure what I missed here and didn't quite understand the usage of action scopes and my actual goal is to define the action to be able to call another python script (.py) how do I modify the code to make it work?

  • 2
    Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour which emphasizes that there should be only one question asked per question. – PolyGeo Nov 14 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.