Sorry if this is a FAQ but the answer’s eluding me.
I’ve coded a simple panel with several properties and a couple of check-boxes. It shows up in the Properties box on the right of the 3D view.
I need to change the values of some of the properties if the user toggles one of the check-boxes, but I can’t find how to run code on a parameter / checkbox change. I can only see how to tie code to operators (buttons).
Is there a way to provide a callback function for parameter changes? Say I needed to let the user specify a start and end frame for recording, and needed to make sure the end frame was never before the start frame - I’d need to run code each time the user changed one of the parameters (ideally as they’re dragging the values).
Googled “blender python checkbox callback” with no luck - what should I be looking for?
def my_prop_callback(self, context):
if context.scene.my_prop:
pass # do something here if user checks checkbox (but not uncheck, just as an example)
bpy.types.Scene.my_prop = bpy.props.BoolProperty(update=my_prop_callback)
pass is a python keyword that you use as a place-holder when building your code structure. You replace it with actual code as you implement your methods.