当前位置: 首页>>代码示例>>Python>>正文


Python QgsProject.layoutManager方法代码示例

本文整理汇总了Python中qgis.core.QgsProject.layoutManager方法的典型用法代码示例。如果您正苦于以下问题:Python QgsProject.layoutManager方法的具体用法?Python QgsProject.layoutManager怎么用?Python QgsProject.layoutManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qgis.core.QgsProject的用法示例。


在下文中一共展示了QgsProject.layoutManager方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testCasting

# 需要导入模块: from qgis.core import QgsProject [as 别名]
# 或者: from qgis.core.QgsProject import layoutManager [as 别名]
    def testCasting(self):
        """
        Test that sip correctly casts stuff
        """
        p = QgsProject()
        p.read(os.path.join(TEST_DATA_DIR, 'layouts', 'layout_casting.qgs'))

        layout = p.layoutManager().layouts()[0]

        # check a method which often fails casting
        map = layout.itemById('map')
        self.assertIsInstance(map, QgsLayoutItemMap)
        label = layout.itemById('label')
        self.assertIsInstance(label, QgsLayoutItemLabel)

        # another method -- sometimes this fails casting for different(?) reasons
        # make sure we start from a new project so sip hasn't remembered item instances
        p2 = QgsProject()
        p2.read(os.path.join(TEST_DATA_DIR, 'layouts', 'layout_casting.qgs'))
        layout = p2.layoutManager().layouts()[0]

        items = layout.items()
        map2 = [i for i in items if isinstance(i, QgsLayoutItem) and i.id() == 'map'][0]
        self.assertIsInstance(map2, QgsLayoutItemMap)
        label2 = [i for i in items if isinstance(i, QgsLayoutItem) and i.id() == 'label'][0]
        self.assertIsInstance(label2, QgsLayoutItemLabel)
开发者ID:boundlessgeo,项目名称:QGIS,代码行数:28,代码来源:test_qgslayoutitem.py


注:本文中的qgis.core.QgsProject.layoutManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。