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

Adam Borczyk adam.borczyk at gis-support.pl
Fri May 25 10:51:38 PDT 2018


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180525/ac34f08f/attachment.html>


More information about the QGIS-Developer mailing list