1
$\begingroup$

How do I make my own 'list' in my custom panel like this? enter image description here

I want to be able to acces to chosen value (string) as well...

Bert

$\endgroup$
3
  • $\begingroup$ Doesn't give me any information on where the list is located or set-up... I suppose they are in files that are not supposed to viewed by the average blender user... $\endgroup$
    – Bert VdB
    Commented Jul 27, 2016 at 12:24
  • 2
    $\begingroup$ You have a complete example in the templates that can be found in the text editor : have a look to "ui_previews_dynamic_enum.py". This sample shows this kind of menu filled with the png files of a directory. $\endgroup$
    – lemon
    Commented Jul 27, 2016 at 12:41
  • 1
    $\begingroup$ Related: blender.stackexchange.com/questions/57306/… $\endgroup$
    – p2or
    Commented Jul 27, 2016 at 12:58

1 Answer 1

1
$\begingroup$

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 :)

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for the extraordinary quick and perfect answer Greg! $\endgroup$
    – Bert VdB
    Commented Jul 27, 2016 at 12:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .