Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-10-21 Thread Nyall Dawson
On Tue, 23 Jan 2018 at 22:34, Enrico Ferreguti wrote: > > 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:

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-24 Thread Nyall Dawson
On 24 January 2018 at 19:20, Etienne Trimaille wrote: > Is-it possible to remove this function from SIP bindings? According to SIP > version? > Unfortunately I don't think this would help - we'd have to remove every method which returns a QgsLayoutItem to do so - and

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-24 Thread Enrico Ferreguti
I'm testing the code under QGIS3, but I fear that isinstance(item, item_class), in my case: isinstance(item, QgsLayoutItemPicture) returns always false because item is of QgsLayoutItem generic class Nyall's workaround works for me without exceptions: from qgis.core import QgsProject,

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-24 Thread Etienne Trimaille
Is-it possible to remove this function from SIP bindings? According to SIP version? It's a common issue, already raised on the mailing list and in plugin issue trackers. I'm copy/pasting another message/snippet from Martin which works perfectly: Not sure if that is related, was just looking

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-23 Thread Nyall Dawson
On 23 January 2018 at 22:34, Enrico Ferreguti wrote: > 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

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-23 Thread Alexander Bruy
2018-01-23 14:34 GMT+02:00 Enrico Ferreguti : > 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

Re: [QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-23 Thread Alessandro Pasotti
On Tue, Jan 23, 2018 at 1:34 PM, Enrico Ferreguti wrote: > 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

[QGIS-Developer] QgsLayout.itemById returns wrong object

2018-01-23 Thread Enrico Ferreguti
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 =