How to fire a function after select element on a UiList

I’ve word in several programming language bue I’m quite new to python, and i dont quite understant the events of it. Right now i’m making an addon where i have markers names and markers frames on a UiList. Everything works fine, i can list everything perfectly.
But i want when i chose(click) an element of the UiList, for it to change the current frame.

My UiList is very simple:

class ListItem(bpy.types.PropertyGroup):

name = StringProperty(
       description="A name for this item",

frame = IntProperty(
       name="Any other property you want",

class MY_UL_List(bpy.types.UIList):

    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):

    # We could write some code to decide which icon to use here...
    custom_icon = 'MARKER_HLT'

    # Make sure your code supports all 3 layout types
    if self.layout_type in {'DEFAULT', 'COMPACT'}:
        layout.label(, icon = custom_icon)

    elif self.layout_type in {'GRID'}:
        layout.alignment = 'CENTER'
        layout.label("", icon = custom_icon)      

#class that draws the UiList

row.template_list(“MY_UL_List”, “The_List”, sce, “my_list”, sce, “list_index” )

register classes

Thank you in advance for your help

You can specify a callback function when registering the list_index property, that should do the trick.

It worked, thank you so much :slight_smile:

In the end it looked like:

def seListIndexFunction(self, value):
bpy.ops.generate_markers.change_marker() #other class function

def register():
bpy.types.Scene.list_index = bpy.props.IntProperty(name = “Index for my_list”, default = 0, update=seListIndexFunction)