[Qgis-developer] Adding new color ramps using python

Nyall Dawson nyall.dawson at gmail.com
Sat Apr 2 13:55:11 PDT 2016


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 )

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


More information about the Qgis-developer mailing list