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?
iface.setActiveLayer(layer). A similar question was asked here. – Joseph Jul 23 '19 at 13:37