I'm currently trying to write a first addon for blender and I would like to be able to have a drop-down menu where I can select one of all available trackers of a scene. (Just like what you can see in the "Follow Track" constraint.

Does anyone know how to achieve sth. like this:

enter image description here

Thank! Any help is much appreciated.


1 Answer 1


This will add a panel in your Properties Window --> Scene Tab called "Layout Demo", which will enable you to select a track if one exists for the 1st Movie Clip added to your scene.

enter image description here

import bpy

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label       = "Layout Demo"
    bl_idname      = "SCENE_PT_layout"
    bl_space_type  = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context     = "scene"

    def draw(self, context):
        layout = self.layout

        scene       = context.scene
        showProp    = False
        tracks      = None
        trackingCam = None

        # Only show this property if there is at least 1 movie clip that has trackers
        if len( bpy.data.movieclips ) > 0:
            mc = bpy.data.movieclips[0] # First movie clip
            if 'Camera' in mc.tracking.objects:
                trackingCam = mc.tracking.objects['Camera']
                tracks      = trackingCam.tracks
                if len( tracks ) > 0:
                    showProp = True

        if showProp and trackingCam and tracks:
            props = context.scene.myprops # Reference property group
            row   = layout.row()
            row.prop_search(props, "tracks", trackingCam, "tracks")

class propsGrp( bpy.types.PropertyGroup ):
    ''' Property group that contains your tracks custom property  '''
    tracks = bpy.props.StringProperty()

def register():
    # Add property group to scene to make it persistent and accessible to panel
    bpy.types.Scene.myprops = bpy.props.PointerProperty(
        type = propsGrp

def unregister():
    # Remove property group from scene when panel is unregistered
    del bpy.types.Scene.props

if __name__ == "__main__":

More about how to use property search.

  • 1
    $\begingroup$ This is perfect, Thanks! Exactly what I needed! $\endgroup$
    – michaelh
    Oct 23, 2016 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .