本文整理汇总了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)