I looked around in the source and other places and I found the code that creates a Color Ramp is as follows:

layout.template_color_ramp(tex, "color_ramp", expand=True)

Does this work for addons because I can't find any documentation or anything on it and whenever I try it doesn't draw in the panel.

I would like to use this in-panel ramp to control a color ramp that is in the Node Editor.


2 Answers 2


While I don't think you can add a new property to an object that can hold the colour ramp data you can display a duplicate of an existing colour ramp in your own panel if you want to. As you want to display the colour ramp that exists within the nodes of an existing material, this can be done with -

cr_node = bpy.data.materials['Material'].node_tree.nodes['ColorRamp']
layout.template_color_ramp(cr_node, "color_ramp", expand=True)

As the name of the colour ramp node may change you will need a way to choose which colour ramp to display, or show all colour ramps in the current material.

  • $\begingroup$ Wow! You are a life saver! :) $\endgroup$
    – doomslug
    Commented Nov 29, 2014 at 19:11

The required pointer property for a color ramp data structure can't be created with Python, it needs to be done in native C code. You can then use Python to create a UI widget and store the data in that property.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .