template_list api changes

Hey there,
due to recent api changes some of my python scripts do not work anymore!
The template list is now managed somehow different!

May someone help me to get this adapted to the current api?
So this works under 2.64. Under 2.65 it doesn’t work anymore!

Here is the blend!
template_list.blend (446 KB)

the api docs:

http://www.blender.org/documentation/blender_python_api_2_65_10/bpy.types.UIList.html

thanks for the hin CoDEmanX,
UIList gives some nice possibilites! My template_list works again! :slight_smile:

So what is the fix for this?
My 2.65 code works fine.


row.template_list(ob, "meshfoot_List", ob, "meshfoot_List_Index","",4,5,'DEFAULT')  # This show list for the collection

But now it does not work in 2.66

How annoying. Why don’t the developers put optional parameters at the end? That is all it would take to keep the API from breaking. I just don’t get it…

Here is the fix:


row.template_list("UI_UL_list","",ob, "meshfoot_List", ob, "meshfoot_List_Index",3,5)  # This show list for the collection

Notice that we now have to put “UI_UL_list”,"" before we list our obj.

Very bad API management practice…(sad face).

If you look at the UIList page that codemanx posted, it says this:

# template_list now takes two new args.
        # The first one is the identifier of the registered UIList to use (if you want only the default list,
        # with no custom draw code, use "UI_UL_list").

So I assume you should just be able to do this:

row.template_list("UI_UL_list", "", ob, "meshfoot_List", ob, "meshfoot_List_Index")

This wasn’t just about a new parameter, we got a whole new RNA type UILayout to allow icons per item. And the limitations of template_list were removed, previously, you could have only one list per panel. API had to change, and the new possibilities are great!