Minor tweaks to preview templates

This commit is contained in:
Campbell Barton 2015-05-12 18:28:05 +10:00
parent 34c78a659b
commit f6dc0e918b
2 changed files with 3 additions and 5 deletions

View File

@ -31,7 +31,7 @@ class PreviewsExamplePanel(bpy.types.Panel):
pcoll = preview_collections["main"]
row = layout.row()
my_icon = pcoll.get("my_icon")
my_icon = pcoll["my_icon"]
row.operator("render.render", icon_value=my_icon.icon_id)
# my_icon.icon_id can be used in any UI function that accepts

View File

@ -14,7 +14,7 @@
# For custom icons, see the template "ui_previews_custom_icon.py".
#
# For distributable scripts, it is recommended to place the icons inside the
# addon directory and access it relative to the py script file for portability:
# script directory and access it relative to the py script file for portability:
#
# os.path.join(os.path.dirname(__file__), "images")
@ -47,11 +47,9 @@ def enum_previews_from_directory_items(self, context):
for i, name in enumerate(image_paths):
# generates a thumbnail preview for a file.
# Also works with previews for 'MOVIE', 'BLEND' and 'FONT'
filepath = os.path.join(directory, name)
thumb = pcoll.load(filepath, filepath, 'IMAGE')
# enum item: (identifier, name, description, icon, number)
enum_items.append((name, name, name, thumb.icon_id, i))
enum_items.append((name, name, "", thumb.icon_id, i))
pcoll.my_previews = enum_items
pcoll.my_previews_dir = directory