I have got a QGIS plugin which creates a layer and add points to it, with those points being read from PDF files. I store the pathnames as attributes and as the final step would like to add an action to the layer so that when the user clicks on a point, the corresponding PDF is opened.
I have implemented the adding of the action like this:
newAct = QgsAction(QgsAction.OpenUrl,'Open report',"""[%concat("Path",'/',"Filename")%]""",False,False)
actionManager = vl.actions()
actionManager.addAction(newAct)
This works, as far as it goes. However, the Action button is disabled until the Action is manually edited to add a scope, since by default no scopes are defined.
It seems that I need to add a scope (e.g. 'Canvas') as the seventh QgsAction argument, something like this:
newAct = QgsAction(QgsAction.OpenUrl,'Open fix report',"""[%concat("Path",'/',"Filename")%]""",'',False,'',scope)
If the 'scope' variable is a string this doesn't work. I believe it needs to be a QSet() object and I think I know the required syntax in C, but not Python. How do I define 'scope' in Python such that it can be used with QgsAction()?
QGIS 3 ; PyQt5 ; Python 3.6.