I have tried to be deliberately detailed in this question: please scroll down to the bottom to see the summary of my question. Thank you.
The UILayout template
template_ID_preview gives a nice selection popup with a preview image for each element.
I am interested in tapping into this feature to improve display of selectors, but I can't find how to remove the "extra" features (outlined in red).
Here is some python code to show what I mean (MVCE in parts).
l.template_ID_preview(properties_texture.context_tex_datablock(context), "active_texture", new="texture.new", rows=2, cols=5)
import bpy import properties_texture def texture_selector(self, context): l = self.layout l.template_ID_preview(properties_texture.context_tex_datablock(context), "active_texture", new="texture.new", rows=2, cols=5) def register(): bpy.types.TEXTURE_PT_context_texture.append(texture_selector) def unregister(): bpy.types.TEXTURE_PT_context_texture.remove(texture_selector) if __name__ == "__main__": register()
To use this, right click on the active texture button, then select "edit source" to see it in the text editor.
Replace this line:
layout.template_ID(idblock, "active_texture", new="texture.new")
layout.template_ID_preview(idblock, "active_texture", new="texture.new", rows=2, cols=3)
Then hit Run Script. This will change the UI from this...
new argument is optional and, if left out, it removes the "+", but there is no such arg for the user count, fake user toggle, and unlink (although unlink is optional, its absence does not remove the associated "x" button).
How can the preview be shown (highlighted in green in the first picture) while removing the rest? Would this only work with custom properties instead of, for example, active texture selection like I show in the screenshot?
I want the template to look more like this screenshot that doesn't have any other settings below the selector:
Please note that this is not the same as the preview for materials, textures, etc. that looks like this:
This is the same sort of thing that the sculpt brush selector tool uses to show a large preview for the brushes.
I don't know what version of Blender this was put in (I notice a lot of new ones since the last time I went through them), but there is now a "ui_previews_dynamic_enum" template in the text editor that demonstrates how to use an icon preview enum like this. It doesn't, of course, talk about linking it with built-in collections such as a materials list as @aliasguru mentions.