6

I've got a plugin where I load some layers. After the last layer loaded, I show the attribute table.

However, I would like to select the form view and not the table view (see image).

How can I do this in Python?

Attribute table layout options

Germán Carrillo
37.3k5 gold badges127 silver badges182 bronze badges
asked Mar 28, 2014 at 14:40

1 Answer 1

4

On QGIS v.2.6 you can open the Attribute table in form view (attribute editor) mode, this way:

  1. Load a layer into QGIS and make it active (that is, click on its name in the ToC).
  2. Open the QGIS Python console.
  3. Paste the following code snippet there:

    from qgis.gui import QgsDualView
    dv = QgsDualView()
    dv.init( iface.activeLayer(), iface.mapCanvas() )
    dv.setView( QgsDualView.AttributeEditor )
    dv.show()
    

And you get (yeah, I know it lacks the toolbar at the top, but that's the most you can get from PyQGIS :D) this:

enter image description here

answered Feb 7, 2015 at 5:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.