[Qgis-developer] Use the style tab widget in a Python plugin

kimaidou kimaidou at gmail.com
Tue Jun 23 09:00:22 PDT 2015


Hi Martin,

Thanks for the help. Now I can display the widget in my scrollArea. I have
still have some crashes, but this is the way to go. I will then need to set
the layer style via a custom "apply" button

Cheers,
Michael

2015-06-23 17:23 GMT+02:00 Martin Dobias <wonder.sk at gmail.com>:

> Hi Michael
>
> The QgsRendererV2Widget is really just abstract base class meant to be
> implemented by custom implementations of renderers.
>
> I think you are looking for this:
>
> from qgis.gui import *
> w=QgsRendererV2PropertiesDialog(iface.activeLayer(),
> QgsStyleV2.defaultStyle(), True)
> w.show()
>
> Cheers
> Martin
>
>
> On Tue, Jun 23, 2015 at 11:09 PM, kimaidou <kimaidou at gmail.com> wrote:
> > Ok, it seems python bindings are missing here. Here is the console output
> >
> >>>> from qgis.gui import *
> >>>> from qgis.core import *
> >>>> rw = QgsRendererV2Widget( iface.activeLayer(),
> QgsStyleV2.defaultStyle()
> >>>> )
> > Traceback (most recent call last):
> >   File "<input>", line 1, in <module>
> > TypeError: qgis._gui.QgsRendererV2Widget represents a C++ abstract class
> and
> > cannot be instantiated
> >
> > Too bad ;)
> >
> >
> >
> > 2015-06-23 16:38 GMT+02:00 kimaidou <kimaidou at gmail.com>:
> >>
> >> Hum...
> >> After digging a little deeper, I found something interesting in the
> Python
> >> Cookbook [1]
> >> It seems I need to use the class QgsRendererV2Widget
> >>
> >> [1]
> >>
> http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/vector.html#creating-custom-renderers
> >>
> >> 2015-06-23 16:29 GMT+02:00 kimaidou <kimaidou at gmail.com>:
> >>>
> >>> Hi all,
> >>>
> >>> The LayerBoard plugin I made during the HF in "Nooooooooodebo" shows a
> >>> table of all vector (and raster) layers and allows to edit some
> properties
> >>> directly by editing the table cells, such as max and min scale, layer
> name,
> >>> title and abstract, assign SRS, etc.
> >>>
> >>> I would like to display the content of the Style tab of the layer
> >>> properties dialog in a panel right to the table. This tab will show the
> >>> style interface refreshed whenever the user clicks on a layer in the
> tab,
> >>> and let her/him change the style for this layer the same way we do via
> the
> >>> layer properties dialog.
> >>>
> >>> I have searched a bit in the api and in the source code, but cannot
> find
> >>> the right way to do so. I have not found a custom Widget which I can
> >>> instantiate with the layer and wich will provide me all the logic
> >>> underneath.
> >>>
> >>> Is this even possible ? Has anyone an idea of how to to this without
> >>> rewriting all the code ( connection between ui elements and slots)
> >>>
> >>> Thanks in advance
> >>>
> >>> Michaël
> >>
> >>
> >
> >
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150623/b55fbe24/attachment.html>


More information about the Qgis-developer mailing list