3
$\begingroup$

I want to create an Add-on with Python.

It should contain an operator that shows several string entries. Each of them can be selected/deselected individually. This is pretty much what happens with Properties/Texture:

enter image description here

I do not need the icon, but the string and the checkbox. I already have a list of strings to be presented to the user.

Similar controls are used for vertex groups, shape keys, uvmaps.

How can I create my own one?

Thank you

Edit:

the modification to the proposed solution is this:

class ULLibraries(UIList):    
    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
        layout.prop(item, "name", text="", emboss=False)
        layout.prop(item, "enabled", text="", index=index)
    def invoke(self, context, event):
        pass 

with following data:

class CustomProp(bpy.types.PropertyGroup):
    name = StringProperty() 
    enabled = BoolProperty() 

Result:

enter image description here

$\endgroup$
  • $\begingroup$ Yes, I found that at a later stage too. At the moment I'm not sure if that is really what I need. The basic framework looks like it is. $\endgroup$ – Monster Dec 21 '15 at 13:03
  • $\begingroup$ I found the difference .... it is how to design the storage [must contain name (string) and a status property (bool)] and the slot (UIList) [show name and status as with layout.prop()]. --- yes it is a doublicate $\endgroup$ – Monster Dec 22 '15 at 5:53
  • $\begingroup$ Hey @Monster! Sorry, don't get it, what else you need? A checkbox? $\endgroup$ – p2or Dec 22 '15 at 11:42
  • $\begingroup$ Yes, I was looking for String + Checkbox. It was not clear to me that it's appearance depends on the property type. $\endgroup$ – Monster Dec 22 '15 at 12:09

Browse other questions tagged or ask your own question.