0

I need to select a specific layer in the layer tree before I run my python script. I have tried Activating layer by its name in PyQGIS? with the code

registry = QgsProject.instance()
layer = registry.mapLayersByName("name")[0]

but on the layer tree, there is no change of focus. The layer does not get selected. How can I accomplish that?

GISme
  • 441
  • 1
  • 3
  • 13

0 Answers0