Color Selector Property?

Can we add a color selector to a custom script’s GUI similarly to the way we add Sting, Int, and Bool Properties?

Yep.

I’m doing something with colours right now. Here is a code snippet. I’ve made the important parts bold.


import bpy


from bpy.props import CollectionProperty, IntProperty, FloatVectorProperty
from bpy.types import PropertyGroup


class z_colour(PropertyGroup):
    h = IntProperty(default=0)
<b>    color = FloatVectorProperty(subtype='COLOR', min=0, max=1)</b>
    
bpy.utils.register_class(z_colour)


bpy.types.Scene.coltable = CollectionProperty(type=z_colour)

Then in the layout


        for color in scene.coltable:
            
            row = layout.row()
            row.prop(color,"h")
           <b> row.prop(color, "color")   #this gives the color box, with wheel/picker on click.</b>

Attachments


you sir…are the MAN!!! :ba:

Kudos from me to, @batFINGER.

You should mark this as solved, @theLuthier.