本文整理汇总了Python中safe_qgis.map.Map.legend方法的典型用法代码示例。如果您正苦于以下问题:Python Map.legend方法的具体用法?Python Map.legend怎么用?Python Map.legend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类safe_qgis.map.Map
的用法示例。
在下文中一共展示了Map.legend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_addClassToLegend
# 需要导入模块: from safe_qgis.map import Map [as 别名]
# 或者: from safe_qgis.map.Map import legend [as 别名]
def test_addClassToLegend(self):
"""Test we can add a class to the map legend."""
myLayer, myType = loadLayer('test_shakeimpact.shp')
del myType
myMap = Map(IFACE)
myMap.setImpactLayer(myLayer)
myMap.legend = None
myColour = QtGui.QColor(12, 34, 126)
myMap.addClassToLegend(myColour,
theMin=None,
theMax=None,
theCategory=None,
theLabel='bar')
myMap.addClassToLegend(myColour,
theMin=None,
theMax=None,
theCategory=None,
theLabel='foo')
myPath = os.path.join(temp_dir(), 'addClassToLegend.png')
myMap.legend.save(myPath, 'PNG')
# As we have discovered, different versions of Qt and
# OS platforms cause different output, so hashes are a list
# of 'known good' renders.
myExpectedHashes = ['', # win
'67c0f45792318298664dd02cc0ac94c3', # ub12.04xiner
'ea0702782c2ed5d950c427fbe1743858', # ub11.04-64
'53e0ba1144e071ad41756595d29bf444', # ub12.04
'0681c3587305074bc9272f456fb4dd09', # ub12.04 xvfb
'a37443d70604bdc8c279576b424a158c', # ub12.04-64
# ub11.04-64 laptop
'944cee3eb9d916816b60ef41e8069683', # binary read
'de3ceb6547ffc6c557d031c0b7ee9e75', # wVistaSP2-32
'',
]
assertHashesForFile(myExpectedHashes, myPath)
示例2: addSymbolToLegend
# 需要导入模块: from safe_qgis.map import Map [as 别名]
# 或者: from safe_qgis.map.Map import legend [as 别名]
def addSymbolToLegend(self):
"""Test we can add a symbol to the legend."""
myLayer, myType = loadLayer('test_floodimpact.tif')
del myType
myMap = Map(IFACE)
myMap.setImpactLayer(myLayer)
myMap.legend = None
mySymbol = QgsSymbol()
mySymbol.setColor(QtGui.QColor(12, 34, 56))
myMap.addSymbolToLegend(mySymbol,
theMin=0,
theMax=2,
theCategory=None,
theLabel='Foo')
myPath = os.path.join(temp_dir(), 'addSymbolToLegend.png')
myMap.legend.save(myPath, 'PNG')
myExpectedHash = '1234'
assertHashForFile(myExpectedHash, myPath)