I am trying to get coordinates from a mouse click in QGIS 3 and python 3 using the plugin builder.
I have tried using the response from this post, and i can manage to get the coordinates printed to the python console in QGIS but at the same time i get the message that "'TypeError: 'QgsMapToolEmitPoint' object is not iterable" or "'QgsMapToolEmitPoint' object does not support indexing"
I can't remember i ever seen a python program causing an error but still manage to compute and output the wanted result. The "not iterable" error traces back to the line with the for loop "for point in ... " the "does not support indexing" error is caused if i do e.g. x = pointTool
Here is a version of the code:
from qgis.gui import QgsMapToolEmitPoint def display_point(pointTool): #print(pointTool) cood =  for point in pointTool: cood.append(point) print(cood) # a reference to our map canvas canvas = iface.mapCanvas() # this QGIS tool emits as QgsPoint after each click on the map canvas pointTool = QgsMapToolEmitPoint(canvas) pointTool.canvasClicked.connect(display_point) canvas.setMapTool(pointTool) display_point(pointTool)