I have this function with:
self.iface.mapCanvas().selectionChanged.connect(self.openThePano)
which waits for a feature selection change to connect to the function openThePano
the issue is that once a single feature is selected the function is called twice and there is only one line that has this signal.
example code:
def actualapp(self):
#waits for the signal
self.iface.mapCanvas().selectionChanged.connect(self.openThePano)
def openThePano(self,fId):
#gets the feature's attributes
featget = fId.selectedFeatures()
atributos = [i.attributes() for i in featget]
source = ogr.Open(self.shproute)
layer = source.GetLayer()
schema = []
ldef = layer.GetLayerDefn()
for n in range(ldef.GetFieldCount()): # gets the attributes' names
fdef = ldef.GetFieldDefn(n)
schema.append(fdef.name)
# This loop prints attributes of the selected feature and is being printed twice.
for i in range(len(atributos[0])):
print('{}: {}'.format(str(schema[i]),str(atributos[0][i])))
self.iface.actionZoomToSelected().trigger()
I expect it to only print once the list of attributes but for some reason I ignore it does it twice, any ideas?