Hi,
I couldn’t find any python code for a color picker under Blender 2.57.
I have found something like Blender.Draw.ColorPicker(), but it is old.
Is there a new way to use a color picker ?
Thanks a lot
Hi,
I couldn’t find any python code for a color picker under Blender 2.57.
I have found something like Blender.Draw.ColorPicker(), but it is old.
Is there a new way to use a color picker ?
Thanks a lot
Remember, the 2.5 interface is written in python, so you can simply browse the python files for clue.
Here is the default simple panel with a color picker property added.
import bpy
class OBJECT_PT_hello(bpy.types.Panel):
bl_label = "Hello World Panel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.label(text="Hello world!", icon='WORLD_DATA')
row = layout.row()
row.label(text="Active object is: " + obj.name)
row = layout.row()
row.prop(obj, "name")
# Material Property Added
mat = bpy.data.materials["Material"]
row.prop(mat, "diffuse_color", text="")
def register():
bpy.utils.register_class(OBJECT_PT_hello)
def unregister():
bpy.utils.unregister_class(OBJECT_PT_hello)
if __name__ == "__main__":
register()
The color picker is activated based upon the TYPE of the property. So to use a custom property value, you will need to create it as a color type.
How to create a custom color property value?
I tried to convert bpy.props.FloatProperty to bpy.props.ColorProperty but of course it doesn’t work
EDIT: use FloatVectorProperty with subtype=‘COLOR’
bpy.types.Scene.customColor = bpy.props.FloatVectorProperty(
name="Value",
description="Color value",
default = (0.0, 0.0, 0.0),
subtype='COLOR'
)
you need to add min and max of 0.0 and 1.0 to make it work properly
Yes! Thanks, it works better like that.
I want add color palette in Blender.
How to create a color picker, without linking (just like colored button) for some material?
Thanks for any help!
the color wheel is a C-coded widget, you can’t extend it with python.
Psy-Fi works on a color palette system, you should contact him via IRC.
I found this add-on http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Paint/Palettes Its code is very complex
And I want create something like it, but simpler. Only 5 color-picker’s elements in “helloworld” panel, without any features.
Can you help me? Please!