0

I know a UIList class is not a big deal to write, but for multiple reasons, I'd like to write one class and use it for handling two PropertyCollection lists. So if I have a class for a UIList like this, can I use it more than once on the same panel for different data in each location in the layout where it's used? If not, what prevents that?

class MY_UL_CustomList(UIList):
    """Demo UIList."""
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
    custom_icon = 'FILE'

    if self.layout_type in {'DEFAULT', 'COMPACT'}:
        layout.label(text = str(index) + '  ' + item.name, icon = custom_icon)
    elif self.layout_type in {'GRID'}:
        layout.alignment = 'CENTER'
        layout.label(text==item.name, icon = custom_icon)

Tango
  • 511
  • 2
  • 22
  • AFAIK there is nothing preventing use of more than one list in a panel. Related https://blender.stackexchange.com/questions/158440/how-to-get-one-uilist-to-control-the-contents-of-another-uilist – batFINGER Apr 07 '21 at 04:51
  • @batFINGER: I thought of including that one as a link, but since he used to separate classes, I thought I should ask - in case there are non-obvious implications. I tested it, but thought it best to ask in case I was out of my depth. My problem, now, is that I've realized I'm not sure how to test just what data list it's using. I see the 3rd from last parameter, when called, is a string with the name of the list, but in the routine, it's scene, as in bpy.context.scene.my_list and I can't see how to be sure it's not using my_list instead of my_2nd_list. I may be posting a question about that. – Tango Apr 07 '21 at 05:07
  • Strike that - found out how to ID which data list I'm working with from within draw_item(). While I can't really get the actual list, I can check the class of the item I'm drawing and use that (as long as both UILists are using different types of data). – Tango Apr 07 '21 at 05:20
  • My gut feel you are going about this A about T. See https://docs.blender.org/api/current/bpy.types.UILayout.html#bpy.types.UILayout.template_list esp notes re list_id – batFINGER Apr 07 '21 at 05:34
  • @batFINGER That's a help, but how do I access the info passed to the UIList in template_list() from within the UIList class I create? I see list_id as a parameter, but I tried to see if it was in the class by accessing it, but it doesn't seem to be in the class. – Tango Apr 07 '21 at 06:45

0 Answers0