How to draw a custom KeyMapItem.properties

My add-on implements a keymap editor. Operator properties are complex, so I want to be able to edit only the members I need.

def draw_keymap_sample( layout ,keyconfing,keymap, idname ) :
    for item in keymap.keymap_items :
        row = layout.row( align = True )
        if item.idname == idname :
            row.template_event_from_keymap_item(item)
            row.prop(item.properties , "tool_mode" , text = "" )

It seems to work, but if you restart Blender, the settings will be lost.
Is there any good solution?

Store them in a “PropertyGroup” in your __init__.py file, then access them via a “PointerProperty”.

Thank you for your advice!
But what I want to change permanently is the content of context.window _ manager.keyconfigs.user.
I made the sample code too simple. More specifically, the code looks like this:.

def draw_keymap_propertie_sample( context , layout ) :
    keyconfing = context.window_manager.keyconfigs.user    
    keymap = keyconfing.keymaps["My Addon" ]        
    for item in reversed(keymap.keymap_items) :
        row = layout.row( align = True )
        if item.idname == "my_operator" :
            row.template_event_from_keymap_item(item)
            row.prop(item.properties , "my_property" , text = "" )

And I want to provide users with such a simple UI.
image

I think this is “read_only” see this.

Maybe this might be a better avenue to explore…

Maybe you can read your own version of it each time Blender starts up, I don’t know…

I tried a lot of different methods,This can be done by notifying a dummy modify to keymap with such an operator.
I don’t think it’s a good way, but is there any other good way?

class SAMPLE_OT_DirtyKeymap(bpy.types.Operator) :
    bl_idname = "addon.sample_dirty_keymap"
    bl_label = "Save Keymap"

    def execute(self, context):
        km = context.window_manager.keyconfigs.user.keymaps["MyAddon"] :
        km.show_expanded_items = km.show_expanded_items
        for kmi in km.keymap_items :
            kmi.active = kmi.active
        context.preferences.is_dirty = True
        return {'FINISHED'}