I'm trying to programmatically set a QgsLayoutPicture content in QGIS3.0:

1) I create a new print composition and I name it 'test'
2) I create a picture frame in the composition and I call it 'picture'
3) I run the following code:

from qgis.core import QgsProject
myLayout = QgsProject.instance().layoutManager().layoutByName('test')
myLayoutPicture = myLayout.itemById("picture")
myLayoutPicture.setPicturePath("path to an image")

and I get the following Exception:
AttributeError: 'QgsLayoutItem' object has no attribute 'setPicturePath'

If I inspect myLayoutPicture object I found it is a
qgis._core.QgsLayoutItem not a QgsLayoutPicture

Is this a correct behaviour or is it an issue? How can I get the right
Layout object?

Regards.
Enrico Ferreguti
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to