Created
October 21, 2015 17:36
-
-
Save Gustry/59d816d15637dfe75c16 to your computer and use it in GitHub Desktop.
Explore the legend tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layer = iface.legendInterface().currentLayer () | |
root = QgsProject.instance().layerTreeRoot() | |
# Find the layer and set the custom property | |
layer_node = root.findLayer(layer.id()) | |
old_value = layer_node.customProperty("showFeatureCount") | |
layer_node.setCustomProperty("showFeatureCount", True) | |
layer_name = layer_node.layerName() | |
tree = iface.layerTreeView() | |
tree_model = tree.layerTreeModel() | |
for i in range(tree_model.rowCount()): | |
node_name = tree_model.index(i,0).data() | |
if layer_name in node_name: | |
import re | |
# (\[(\d*)\]$) | |
# match = re.search | |
#todo | |
layer_node.setCustomProperty("showFeatureCount", old_value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment