TransWikia.com

Opening attribute table using PyQgis?

Geographic Information Systems Asked by redfrex on February 11, 2021

Is it possible to open an attribute table from the Python console or through a Python script in QGIS?

One Answer

Yes you can, at least with the latest master version and 1.8. It is a method exposed via iface

// C++ (signature)
void showAttributeTable (QgsVectorLayer *l)

# PyQGIS (example)
iface.showAttributeTable(iface.activeLayer())

You will need a preexisting reference to a QgsVectorLayer.

For direct editing of features it is also a method exposed via iface:

// C++ (signature)
bool openFeatureForm (QgsVectorLayer *l, QgsFeature &f, bool updateFeatureOnly=false)

# PyQGIS (example)
iface.openFeatureForm(iface.activeLayer(), feature, False)

You will need a preexisting reference to a QgsVectorLayer and a QgsFeature in both cases. The feature form opened and whether it is editable are dependent upon app settings and whether the feature's layer is in edit mode.

Answered by dakcarto on February 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP