[Qgis-developer] Adding new color ramps using python
Anita Graser
anitagraser at gmx.at
Sat Apr 2 15:27:50 PDT 2016
On Sat, Apr 2, 2016 at 10:55 PM, Nyall Dawson <nyall.dawson at gmail.com>
wrote:
> On 3 April 2016 at 06:41, Anita Graser <anitagraser at gmx.at> wrote:
> > Hi,
> >
> > Is it possible to directly add new color ramps to QGIS using Python?
> > I know that it's possible to write style xml files for color ramps which
> can
> > then be imported but a more direct solution would be great.
>
> Untested, but something like
>
> ramp = QgsVectorGradientColorRampV2( color1, color2 )
> tags=[]
> QgsStyleV2.defaultStyle().saveColorRamp( 'my ramp', ramp, 0, tags )
>
​Thanks Nyall, that worked great! I used both saveColorRamp() and
addColorRamp() to save permanently but still have the new ramp appear
without having to restart QGIS.
Best wishes,
Anita
>
> should work.
>
> See https://qgis.org/api/classQgsVectorGradientColorRampV2.html and
> https://qgis.org/api/classQgsStyleV2.html#a14a66fbd382fa858cbc8cd73d394724d
>
> Nyall
>
> >
> > Thanks and best wishes,
> > Anita
> >
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160403/b793e007/attachment.html>
More information about the Qgis-developer
mailing list