2
$\begingroup$

Hey I have a questions

I have a prop_search which is filled with names. Is there some kind of callback when I change the selection of the prop_search? like I have this:

def draw(self, context):
    col = layout.column()        
    col.prop_search(context.scene, "hdri", context.scene, "coll", icon='OBJECT_DATA')

can I somehow define a function that is triggered whenever I change the prop_search?


I'm pretty new to Python for Blender.

$\endgroup$
2
  • $\begingroup$ alright, I deleted the second question :) $\endgroup$
    – Domi
    Aug 6, 2015 at 8:21
  • $\begingroup$ Domi do you understand the new title to this question? (what an RNA property is) $\endgroup$
    – zeffii
    Aug 6, 2015 at 13:54

1 Answer 1

2
$\begingroup$

Yes, for any property, you can define a set and update callbacks.

These are functions you define, passed as an argument and called by Blender whenever the property changes.

  • get - you can return the value and store it wherever you like.
  • set - you're responsible for making sure the new value is stored/modified.
  • update - is called after setting, often used to ensure related data is updated.

See: http://www.blender.org/api/blender_python_api_2_75_release/bpy.props.html#bpy.props.EnumProperty


In the example above, you would have to set the callback on the hdri property definition.

$\endgroup$
3
  • 1
    $\begingroup$ thanks, but I'm confused, how can I set an update-function for my example above? $\endgroup$
    – Domi
    Aug 6, 2015 at 9:14
  • $\begingroup$ @Domi, updated answer. $\endgroup$
    – ideasman42
    Aug 6, 2015 at 10:49
  • $\begingroup$ @Domi: you can't define a callback in UI code (panel / prop_search). It must be specified for the property when it is set up. $\endgroup$
    – CodeManX
    Aug 7, 2015 at 18:40

You must log in to answer this question.

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