0

I can load a layer, open a canvas, and draw the layer in the canvas using the Qgis python API.

Can I bring up the properties dialog, or even just the "Style" tab of the properties dialog, from such a standalone application? I have a bad feeling I can't because all the code is in the main Qgis Application rather than present in qgis.core and qgis.gui, and doesn't have a python interface.

Unless I've missed something, the solution might be to rebuild the dialog and its behaviour in Python, re-using the relevant .ui file?

3
  • Do you need style or labels also? Style is all in gui but labels are not yet.
    – Nathan W
    Commented Jun 24, 2016 at 10:30
  • Style would be good for a start! I should probably add I'm using 2.14 Essen at the moment.
    – Spacedman
    Commented Jun 24, 2016 at 10:37
  • You can take a look at webgeodatavore.github.io/pyqgis-samples (disclaimer: I'm the author or this content) to find out most Python QGIS gui API components visually with sample code.
    – ThomasG77
    Commented Jun 24, 2016 at 14:17

1 Answer 1

0

You can use the following dialog if you need only style:

QgsRendererV2PropertiesDialog

Usage:

dlg = QgsRendererV2PropertiesDialog(layer, QgsStyleV2.defaultStyle(), embedded=False)
dlg.setMapCanvas(canvas)
dlg.exec_()
1
  • Yes! Needs a canvas.refresh() to reflect changes unless I can add an "apply" button with my Qt skillz...
    – Spacedman
    Commented Jun 24, 2016 at 10:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.