forked from bartvdbraak/blender
Minor tweaks to preview templates
This commit is contained in:
parent
34c78a659b
commit
f6dc0e918b
@ -31,7 +31,7 @@ class PreviewsExamplePanel(bpy.types.Panel):
|
|||||||
pcoll = preview_collections["main"]
|
pcoll = preview_collections["main"]
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
my_icon = pcoll.get("my_icon")
|
my_icon = pcoll["my_icon"]
|
||||||
row.operator("render.render", icon_value=my_icon.icon_id)
|
row.operator("render.render", icon_value=my_icon.icon_id)
|
||||||
|
|
||||||
# my_icon.icon_id can be used in any UI function that accepts
|
# my_icon.icon_id can be used in any UI function that accepts
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# For custom icons, see the template "ui_previews_custom_icon.py".
|
# For custom icons, see the template "ui_previews_custom_icon.py".
|
||||||
#
|
#
|
||||||
# For distributable scripts, it is recommended to place the icons inside the
|
# 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")
|
# 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):
|
for i, name in enumerate(image_paths):
|
||||||
# generates a thumbnail preview for a file.
|
# generates a thumbnail preview for a file.
|
||||||
# Also works with previews for 'MOVIE', 'BLEND' and 'FONT'
|
|
||||||
filepath = os.path.join(directory, name)
|
filepath = os.path.join(directory, name)
|
||||||
thumb = pcoll.load(filepath, filepath, 'IMAGE')
|
thumb = pcoll.load(filepath, filepath, 'IMAGE')
|
||||||
# enum item: (identifier, name, description, icon, number)
|
enum_items.append((name, name, "", thumb.icon_id, i))
|
||||||
enum_items.append((name, name, name, thumb.icon_id, i))
|
|
||||||
|
|
||||||
pcoll.my_previews = enum_items
|
pcoll.my_previews = enum_items
|
||||||
pcoll.my_previews_dir = directory
|
pcoll.my_previews_dir = directory
|
||||||
|
Loading…
Reference in New Issue
Block a user