a little question about UI list, i'm trying to make a custom marker panel. It's aim is to recense all markers on timeline. Then i have a custom operator to jump to these markers. I managed to call the UIlist, but i want it to be sorted by frame number (the marker at the frame number 1 being automatically above marker at frame number 2) and i have no clue to do that. For now i just managed to display frames number for more clearity... Here's my piece of code so far :
import bpy
from bpy.props import IntProperty, CollectionProperty , StringProperty
from bpy.types import Panel, UIList
import os
# custom list
class Markers_items(UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
split = layout.split(0.8)
layout.prop(item, "name", text="", icon='MARKER', emboss=False, translate=True)
split.label("%d" % (bpy.context.scene.timeline_markers[index].frame))
def invoke(self, context, event):
pass
# draw the panel
class MarkerListPanel(Panel):
"""Creates a Panel in the Object properties window"""
bl_space_type = 'FILE_BROWSER'
bl_region_type = 'TOOLS'
bl_category = "Editing Tools"
bl_label = "Markers List"
def draw(self, context):
layout = self.layout
scn = bpy.context.scene
rows = 2
row = layout.row(align=False)
row.template_list("Markers_items", "", scn, "timeline_markers", scn, "marker_index", rows=rows)
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.marker_index = IntProperty()
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.marker_index
if __name__ == "__main__":
register()
I don't have a clue about that... Any help ? Thanks in advance to all ! :D