def path_menu(self, searchpaths, operator, props_default={}):
layout = self.layout
# hard coded to set the operators 'filepath' to the filename.
import os
import bpy.utils
layout = self.layout
if not searchpaths[0]:
layout.label("* Missing Paths *")
# collect paths
else:
files = []
for directory in searchpaths:
files.extend([(f, os.path.join(directory, f)) for f in os.listdir(directory)])
files.sort()
for f, filepath in files:
if f.startswith("."):
continue
preset_name = bpy.path.display_name(f)
props = layout.operator(operator, text=preset_name)
for attr, value in props_default.items():
setattr(props, attr, value)
props.filepath = filepath
if operator == "palette.load_gimp_palette":
props.menu_idname = self.bl_idname
评论列表
文章目录