本文整理汇总了Python中qgis.core.QgsLayoutGridSettings类的典型用法代码示例。如果您正苦于以下问题:Python QgsLayoutGridSettings类的具体用法?Python QgsLayoutGridSettings怎么用?Python QgsLayoutGridSettings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QgsLayoutGridSettings类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createComposition
def createComposition(self):
'''
Create a print Layout
'''
c = QgsPrintLayout(self.mProject)
c.initializeDefaults()
c.setUnits(QgsUnitTypes.LayoutMillimeters)
g=QgsLayoutGridSettings(c)
g.setOffset( QgsLayoutPoint(3.5, 0, QgsUnitTypes.LayoutMillimeters) )
g.setResolution( QgsLayoutMeasurement(2.5) )
# Set page number
self.getPageNumberNeeded()
# Set main properties
for i in range(1, self.numPages):
p=QgsLayoutItemPage(c)
#page.setPageSize('A6')
p.setPageSize( QgsLayoutSize(self.pageWidth, self.pageHeight, QgsUnitTypes.LayoutMillimeters) )
c.pageCollection().addPage(p)
# Set the global currentComposition
self.currentComposition = c
示例2: testReadWriteXml
def testReadWriteXml(self):
p = QgsProject()
l = QgsLayout(p)
s = QgsLayoutGridSettings(l)
s.setResolution(QgsLayoutMeasurement(5, QgsUnitTypes.LayoutPoints))
s.setOffset(QgsLayoutPoint(6, 7, QgsUnitTypes.LayoutPixels))
doc = QDomDocument("testdoc")
elem = doc.createElement("test")
self.assertTrue(s.writeXml(elem, doc, QgsReadWriteContext()))
s2 = QgsLayoutGridSettings(l)
self.assertTrue(s2.readXml(elem.firstChildElement(), doc, QgsReadWriteContext()))
self.assertEqual(s2.resolution().length(), 5.0)
self.assertEqual(s2.resolution().units(), QgsUnitTypes.LayoutPoints)
self.assertEqual(s2.offset().x(), 6.0)
self.assertEqual(s2.offset().y(), 7.0)
self.assertEqual(s2.offset().units(), QgsUnitTypes.LayoutPixels)
示例3: testGettersSetters
def testGettersSetters(self):
p = QgsProject()
l = QgsLayout(p)
s = QgsLayoutGridSettings(l)
s.setResolution(QgsLayoutMeasurement(5, QgsUnitTypes.LayoutPoints))
self.assertEqual(s.resolution().length(), 5.0)
self.assertEqual(s.resolution().units(), QgsUnitTypes.LayoutPoints)
s.setOffset(QgsLayoutPoint(6, 7, QgsUnitTypes.LayoutPixels))
self.assertEqual(s.offset().x(), 6.0)
self.assertEqual(s.offset().y(), 7.0)
self.assertEqual(s.offset().units(), QgsUnitTypes.LayoutPixels)
s.setPen(QPen(QColor(255, 0, 255)))
self.assertEqual(s.pen().color().name(), QColor(255, 0, 255).name())
s.setStyle(QgsLayoutGridSettings.StyleDots)
self.assertEqual(s.style(), QgsLayoutGridSettings.StyleDots)