I want to know if there is signals in layers tree to get notified when the active layer changed or more precisely when the user clicks or dbl click on any layer or node in the layers tree view.
I search in QGIS documentation but found nothing!
I have the solution after playing around here in the related questions to my question:
def test(lyr): print(lyr.id()) iface.legendInterface().currentLayerChanged.connect(test)
the sample code above is not perfect but showing the solution, the signal
currentLayerChanged fires every time the user changes the selected node or item (layer) in the layers treeview.
def test(lyr): print(lyr.id()) iface.layerTreeView().currentLayerChanged.connect(test)