Could I see a simple example of using a color picker in a script? I've seen a lot of variations of using color pickers, but I want to see just a simple, clear example of being able to bring up a color picker (with a default color set), pick a color, and being able to get the value from that color picker either as a return value after it's picked, or being able to access that value at another time.
One resource that has helped me some is this answer on another SE:Blender question. In that case, the script provided 5 color pickers. I edited it some, both to help me understand it and to make it work as just a single color picker:
import bpy

class ColorItem(bpy.types.PropertyGroup):
    color = bpy.props.FloatVectorProperty(
                 name = &quot;Color Picker&quot;,
                 subtype = &quot;COLOR&quot;,
                 size = 4,
                 min = 0.0,
                 max = 1.0,
                 default = (1.0,1.0,1.0,1.0)
                 )

class ColorPanel(bpy.types.Panel):
    &quot;&quot;&quot;Creates a Panel in the Scene properties window&quot;&quot;&quot;
    bl_label = &quot;Colors&quot;
    bl_idname = &quot;SCENE_PT_colors&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;scene&quot;

    def draw(self, context):
        row = self.layout.row()
        row.prop(context.scene.colors[0], &quot;color&quot;, text='Pick Color')

def register():
    bpy.utils.register_class(ColorPanel)
    bpy.utils.register_class(ColorItem)

def unregister():
    bpy.utils.unregister_class(ColorPanel)
    bpy.utils.unregister_class(ColorItem)

if __name__ == &quot;__main__&quot;:
    register()
    bpy.types.Scene.colors = bpy.props.CollectionProperty(type=ColorItem)
    bpy.context.scene.colors.add()

While just a simple example would provide me with what I need (again, with me being able to set the default color and being able to get the color value either as a return value or to get it when I need it), there are parts in this script I don't understand and would like to. Also, on that 2nd to last line, I'm not sure just how the object creation is done. By passing &quot;type=ColorItem&quot; to bpy.props.CollectionProperty(), is it returning an object of that class? (I'm assuming it does, but realize I don't understand all that's going on there.)
Also, on the last line, just what is being added to bpy.context.scene.colors?
I don't see the difference (in the last part) between &quot;Scene&quot; (2nd to last line) and using &quot;scene,&quot; but capitalizing it instead of keeping it lower case. There's also the object in the draw subroutine context.scene.colors. Are they the same object?
When I've tried to figure out just what kind of object I'm working with, even with the ColorItem class in this code, I'm not clear how there are 16 of this item, and not just one, and why that class is not just a single floating point vector with 4 parts that makes up the color.
Any explanation of this that would clarify things for me would be a big help.
Just declare a FloatVectorProperty, set its subtype to 'COLOR' and add it to a panel or whatever.
my_color = bpy.props.FloatVectorProperty(
             name = &quot;Color Picker&quot;,
             subtype = &quot;COLOR&quot;,
             default = (1.0,1.0,1.0,1.0)
             size = 4
             )

In order to access the values of the property, you would have to create an Operator. Minimal working example, adds a new panel to the render settings, allows to pick a color as well as printing the values to the console. Further reading: How to create a custom UI?

import bpy

class SimpleOperator(bpy.types.Operator):
    &quot;&quot;&quot;Tooltip&quot;&quot;&quot;
    bl_idname = &quot;object.simple_operator&quot;
    bl_label = &quot;Simple Object Operator&quot;

    def execute(self, context):
        clr = context.scene.mytool_color
        print (clr[0], clr[1], clr[2], clr[3])
        return {'FINISHED'}


class HelloWorldPanel(bpy.types.Panel):
    &quot;&quot;&quot;Creates a Panel in the Object properties window&quot;&quot;&quot;
    bl_label = &quot;Hello World Panel&quot;
    bl_idname = &quot;OBJECT_PT_hello&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;render&quot;

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.prop(context.scene, &quot;mytool_color&quot;)
        row = layout.row()
        row.operator(SimpleOperator.bl_idname)
        
def register():
    bpy.utils.register_class(HelloWorldPanel)
    bpy.utils.register_class(SimpleOperator)
    
    # Register the property per Scene, Object or whatever
    bpy.types.Scene.mytool_color = bpy.props.FloatVectorProperty(
                 name = &quot;Color Picker&quot;,
                 subtype = &quot;COLOR&quot;,
                 size = 4,
                 min = 0.0,
                 max = 1.0,
                 default = (1.0,1.0,1.0,1.0))
    
def unregister():
    bpy.utils.unregister_class(SimpleOperator)
    bpy.utils.unregister_class(HelloWorldPanel)
    
    del bpy.types.Scene.mytool_color


if __name__ == &quot;__main__&quot;:
    register()