How do I make my own 'list' in my custom panel like this?
I want to be able to acces to chosen value (string) as well...
Bert
How do I make my own 'list' in my custom panel like this?
I want to be able to acces to chosen value (string) as well...
Bert
That is an Enum Property, essentially an array of options that have an identifying name, a displayed name, and a description (shown in the tooltip).
For example:
bpy.types.Scene.MyEnum = EnumProperty(
items = [('one', 'One!', 'The first number'),
('two', 'Two', 'The second number'),
('three', 'Three', 'The third number')],
default = "one",
description = "Pick a number",
name = "Numbers")
For the first item, "one" is the identifier, "One!" is the name shown in the interface, and "The first number" is shown in the tooltip.
You would access the chosen option using scene.MyEnum
, and set it using scene.MyEnum="two"
.
To display the enum in the interface and allow the user to change it, use layout.prop(scene, 'MyEnum')
Note: The code snippets here are very helpful :)