# Note

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.

# Background

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).

### Minimal:

l.template_ID_preview(properties_texture.context_tex_datablock(context),
"active_texture",
new="texture.new",
rows=2,
cols=5)


### Complete:

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()


### Verifiable:

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")


With this:

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...

...to this:

The 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).

# Question

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.

• Suggest using template_preview – batFINGER Dec 21 '16 at 9:08
• @batFINGER That is the built-in preview for material, textures, lamps, etc. I want a "selector" with the large preview. I have added another picture to my question to illustrate this. – JakeD Dec 21 '16 at 13:04
• That type of customisation is a bit more involved. It is basically done using template_icon_view instead of template_ID_preview. But you need to indeed generate custom properties to hold the preview collection. Haven't tested if it could be combined somehow with existing collections, but honestly I doubt it. template_icon_view is really designed to show image content which is located somewhere on a file storage, like in the case of Pro_Lighting_Skies and the like. – aliasguru Dec 21 '16 at 13:52

Firstly, you should understand if you are presenting ID or non-ID properties. If they are just temporary properties, template_icon_view should be used instead of template_ID_preview.
If you want just a preview with no management options, but also with no selector, there istemplate_preview. The buttons on the side are optional.
The template_icon_view was introduced along with the matcaps for Blender 2.66, but the ability to have custom previews from files is from 2.75. https://wiki.blender.org/index.php/User:Brita/Proposals/UIPreviews