1

I want to use the "Identify Feature Tool" in code (PyQGIS3). What I've found in the internet doesn't use the tool, people usually print in console point features and ids. I also found a tool that would open a window form with the point information but this method won't get attached to the docks or update itself.

I am providing examples of the methods I found below:

METHOD 1 (Printing features on console):

atriVector = self.iface.mapCanvas().currentLayer()
featget = atriVector.getFeatures()

atributes = [i.attributes() for i in featget]

print("{}".format(atributes[0][0]))

METHOD 2 (opening a feature form):

atriVector = self.iface.mapCanvas().currentLayer()
f = atriVector.selectedFeatures()[0]
self.iface.openFeatureForm(atriVector, f)

This method as I said before won't update itself, it would open a new window for every selected feature.

These two methods are the ones closer to what I am expecting (which is the actual tool from QGIS interface)

Here is an screenshot of it:

I want to use this tool with PyQGIS, but I have only found previous methods which are not close to what I expect.

Identify Feature Tool

See that in the image there is a selected feature and in the box the information of the feature is shown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.