Changing multiple shrinkwrap bone constraint targets from UI panel at once

I have this little script that lets me change the target of the shrinkwrap constraints of bones “Bone” and “Bone.001” of an armature object, (the script and an example file are both attached.) However, I have to change the targets for each bone separately. Is it possible to create a UI panel that allows you to choose a single object (preferably from an enumerated drop-down list like both fields have now) and set it as the target for multiple bones’ constraint, from a single field?

import bpy

class BoneSWTest(bpy.types.Panel):
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    bl_label = "Bone Shrinkwrap Test"
    def poll(self, context):
        if not context.active_object:
            return False
        return True
    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.prop(bpy.context.object.pose.bones["Bone"].constraints["Shrinkwrap"], 'target', text='Bone target')
        row = layout.row()
        row.prop(bpy.context.object.pose.bones["Bone.001"].constraints["Shrinkwrap"], 'target', text='Bone.001 target')


Shrinkwrap Controller.blend (516 KB)

This function checks if there’s already a shrinkwrap constraint set in each selected pose bone, and sets the object given in the parameter.
You can turn this into a UI panel by executing the function with an operator and a field to insert the object name, or by creating a dropdown of the current objects in the scene which is not so straight forward (maybe this helps

import bpy

def setShrinkWrapTarget(target_object):
    if bpy.context.mode == 'POSE':
        for bone in bpy.context.selected_pose_bones:
            for cons in bone.constraints:
                    if cons.type == "SHRINKWRAP":
               = target_object



That link has a function that was tested with Blender 2.52 - which means it’s just about gibberish to current Blender versions. I don’t know nearly enough to begin to translate it, so is there a way to get the drop-down list of objects in a scene as seen in constraints, etc., themselves?