[QGIS-Developer] QgsLayout returns different types on different platforms

Tim Sutton tim at kartoza.com
Fri May 25 12:43:18 PDT 2018


Hi

It is probably a well known issue with SIP bindings not recognising the object type returned for the layout. A work around is here:

https://github.com/inasafe/inasafe/blob/develop/safe/report/processors/default.py#L54

Regards

Tim

> On 25 May 2018, at 19:51, Adam Borczyk <adam.borczyk at gis-support.pl> wrote:
> 
> Hi all,
> Using PyQGIS I load a layout .qpt file, then I access items in the composition. I do it using
> 
>         document = QDomDocument()
>         document.setContent(content) # content is .qpt file content
>         composition = QgsPrintLayout( QgsProject.instance() )
>         composition.loadFromTemplate( document, QgsReadWriteContext() )
> 
>         map_item = composition.itemById('main_map')
>         map_item.setExtent(canvas.extent())
> 
> 
> Now map_item is of type QgsLayoutItemMap while I'm on Ubuntu, but it is QgsLayoutItem when I use Windows and therefore I receive an error (QgsLayoutItem does not have setExtent method). Does anybody have an idea why this happens?
> 
> Ubuntu 16.04 x64 + QGIS 3.0.2 with Python 3.5.2 installed last week
> Windows 7 x64 + QGIS 3.0.3 with Python 3.6.0 (fresh now from OSGeo Installer)
> 
> Best regards
> Adam Borczyk
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

—








Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org

Visit http://kartoza.com <http://kartoza.com/> to find out about open source:

Desktop GIS programming services
Geospatial web development
GIS Training
Consulting Services

Skype: timlinux
IRC: timlinux on #qgis at freenode.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180525/0b4df3bd/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: KartozaNewLogoThumbnail.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180525/0b4df3bd/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180525/0b4df3bd/attachment-0001.sig>


More information about the QGIS-Developer mailing list