I've been searching for a while to find a way to pass the layer that caused a signal to another function. I have a list of layers that that I want to apply automated attributes to. This has complicated this task a bit.
I've looked at some similar posts (1), but haven't been able to apply any solution to the code below.
from qgis.core import * from qgis.utils import iface from PyQt4.QtGui import * list_editable_layers = [layer1, layer2, layer3] def openProject(): # list the layers to listen to for edits editLayers = list_editable_layers for l in editLayers: # Update feature attributes when new features are added or geometry changes l.featureAdded.connect(updateFeatureAttrs) l.attributeValueChanged.connect(updateFeatureAttrs) l.geometryChanged.connect(updateFeatureAttrs) def updateFeatureAttrs( fId, geom=None ): # how do you pass the layer that cuased the signal to this function? editLayer = iface.activeLayer() def saveProject(): pass def closeProject(): pass