本文整理匯總了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)