Integrated a setter into a PropertyGroup that will be linked to a UILIst

Hy everyone,

I’ve got a UIList that records the names of the bones from an armature on the stage. I have a PropertyGroup “BONE_PG_” which is linked to this list.

When I change the name in the list, I try to change the name of the bones in the scene as well. For this I would like to change the name setter to do this.The problem is that at the initialization of the list I don’t see what to set to rename the bone in the short record in the list. I’ve tried a lot of things but as soon as I use set_name_bone the name is not recognised.

def set_name_bone(self, n):

    if list_init :
        # set the name of the bone being init
   else :
       # set the name of the index of the list (bones_map_index)
       # rename the bone in the scene
class BONE_PG_(bpy.types.PropertyGroup):
   
    name : bpy.props.StringProperty(name="undetected",description='UIList property', default="Unknown", get=get_name_bone , set=set_name_bone)
def build_bones_list():

    context = bpy.context
    scene = bpy.context.scene
    arm= scene.arma_props
    
    arm.obj = context.active_object # set the Armature
    pose_bones = arm.obj.pose.bones #bones of the Armature
    
    for i in pose_bones:
        
        item = scene.bones_map.add()
        item.name = i.name
        
    scene.bones_map_index = 0
class EX_UL_items(bpy.types.UIList):
    
   def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        layout.prop(item, "name", text="", emboss=False, translate=False)
c.template_list("EX_UL_items", "", scene, "bones_map", scene, "bones_map_index", rows=1)
bpy.types.Scene.bones_map = bpy.props.CollectionProperty(type=BONE_PG_)
    
bpy.types.Scene.bones_map_index = bpy.props.IntProperty()

Good Day,

I did not fully understand the question
If you ask how to rename the StringProperty in your PropertyGroup, here’s an example

def set_name_bone(self, value):
    self["name"] = value

And here’s an example of the get function

def get_name_bone(self):
    return self["name"]

Sorry, I got completely lost in the code and made things unnecessarily complicated. I used the code you presented but I used it very badly.

Thank you for your answer.