# Display Value of a nodes RGB input in a panel

I have a Mix RGB node and want to display the input in a normal panel in the UI. I can show the color widget by using layout.prop(input,"default_value"), but what I want to do is to just show the Value of the input. This would then show a float input instead of the color widget.

Use the indexed element, eg red is index 0

For array properties can display an individual element in a layout.prop(...) by specifying the index of the array element. Eg for the red channel of mix color input input.default_value

layout.prop(input, "default_value", index=0)


The color node socket input has a type 'RGBA'

def draw(self, context):
layout = self.layout
# node for testing
node = bpy.data.materials["Material"].node_tree.nodes["Mix"]
input = node.inputs["Color1"]
col = layout.column(align=True)
for i, c in enumerate(input.type):
col.prop(
input, "default_value",
text=c.upper(),
index=i)


What about using a label? I haven't tested the following, but something like this:

value_string = "({:.1f}, {:.1f}, {:.1f})".format(
input.default_value[0],
input.default_value[1],
input.default_value[2])

layout.label(text=value_string)

• This just displays the different values. What I want, is to display the Value as in HueSaturationValue as a layout.prop(...) – Joshua Knauber May 1 '19 at 19:09
• There may be a better way, but what about creating three new float properties and having some python set the node color when they are changed? – gandalf3 May 1 '19 at 19:14
• Yeah I guess that'd be possible, I hoped there was a better way, but maybe I just have to do that. – Joshua Knauber May 1 '19 at 19:29