# How detect change in a panel

Is it possible to detect a change in a panel (as a compartment which we mark or a slider which we move) to launch a update function but only if the change is in a panel as T, N, Property panel ect... ?

You can only bind callbacks to properties, but you can't determine the origin of a change event.

It will be called the same way regardless of whether the user dragged a slider in a panel here, or ticked a checkbox in a panel there, or if he/she or another script changed the property programmatically.

Sorry to answer my own question but that will can be use to somebody else. I finally found this solution:

def currentSculptProperties():
show_text = bpy.context.window_manager.show_text
current_sculpt_properties = []
tool_settings = bpy.context.scene.tool_settings
Detail_Size = tool_settings.sculpt.detail_size
Constant_Detail = tool_settings.sculpt.constant_detail
if(hasattr(tool_settings.sculpt, 'detail_percent')):
Detail_Percent = tool_settings.sculpt.detail_percent
active_brush = bpy.context.tool_settings.sculpt.brush.name
detail_refine = tool_settings.sculpt.detail_refine_method
Detail_Type = tool_settings.sculpt.detail_type_method

if bpy.context.sculpt_object.use_dynamic_topology_sculpting:
if show_text.refine_method:
if tool_settings.sculpt.detail_type_method == 'RELATIVE':
current_sculpt_properties.append(Detail_Size)
elif tool_settings.sculpt.detail_type_method == 'CONSTANT':
current_sculpt_properties.append(Constant_Detail)
elif tool_settings.sculpt.detail_type_method == 'BRUSH':
current_sculpt_properties.append(Detail_Percent)
if show_text.detail_type:
current_sculpt_properties.append(Detail_Type)
current_sculpt_properties.append(tool_settings.unified_paint_settings.size)
if show_text.brush_strength:
current_sculpt_properties.append(bpy.data.brushes[active_brush].strength)
if show_text.symmetry_use:
if tool_settings.sculpt.use_symmetry_x:
current_sculpt_properties.append(tool_settings.sculpt.use_symmetry_x)
if tool_settings.sculpt.use_symmetry_y:
current_sculpt_properties.append(tool_settings.sculpt.use_symmetry_y)
if tool_settings.sculpt.use_symmetry_z:
current_sculpt_properties.append(tool_settings.sculpt.use_symmetry_z)

return current_sculpt_properties

def updateTextHandlers(scene):
show_text = bpy.context.window_manager.show_text
mode = bpy.context.object.mode
if mode == 'SCULPT' and show_text.sculpt_use:
if currentSculptProperties() not in show_text.sculpt_properties_pre:
show_text.sculpt_properties_pre[:] = []
show_text.sculpt_properties_pre.append(currentSculptProperties())
sculptInfo()


Maybe it's not the simplest way, but she works.

• .Looks like you left out some important bits (how is the handler function invoked?), and the indentation is slightly broken. – CodeManX Aug 2 '15 at 19:17