當前位置: 首頁>>代碼示例>>Python>>正文


Python props.EnumProperty方法代碼示例

本文整理匯總了Python中bpy.props.EnumProperty方法的典型用法代碼示例。如果您正苦於以下問題:Python props.EnumProperty方法的具體用法?Python props.EnumProperty怎麽用?Python props.EnumProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在bpy.props的用法示例。


在下文中一共展示了props.EnumProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    bpy.types.Scene.save_after_render = BoolProperty(
                    name='Save after render',
                    default=True,
                    description='Automatically save rendered images into: //auto_save/')
    bpy.types.Scene.save_blend = BoolProperty(
		    name = 'with .blend',
                    default=True,
                    description='Also save .blend file into: //auto_save/')	
    bpy.types.Scene.auto_save_format = EnumProperty(
                    name='Auto Save File Format',
                    description='File Format for the auto saves.',
                    items={
                    ('PNG', 'png', 'Save as png'),
                    ('JPEG', 'jpg', 'Save as jpg'),
                    ('OPEN_EXR_MULTILAYER', 'exr', 'Save as multilayer exr')},
                    default='PNG')
    bpy.types.Scene.auto_save_subfolders = BoolProperty(
                    name='subfolder',
                    default=False,
                    description='Save into individual subfolders per blend name')
    bpy.app.handlers.render_post.append(auto_save_render)
    bpy.types.RENDER_PT_render.append(auto_save_UI) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:25,代碼來源:render_auto_save.py

示例2: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    from bpy.types import WindowManager
    from bpy.props import EnumProperty

    WindowManager.lls_tex_previews = EnumProperty(
            items=enum_previews_from_directory_items,
            get=preview_enum_get,
            set=preview_enum_set,
            )
    import bpy.utils.previews
    pcoll = bpy.utils.previews.new()
    pcoll.lls_tex_previews = ()
    pcoll.initiated = False
    pcoll.dir_update_time = os.path.getmtime(directory)

    preview_collections["main"] = pcoll 
開發者ID:leomoon-studios,項目名稱:leomoon-lightstudio,代碼行數:18,代碼來源:light_preview_list.py

示例3: getCategoriesForEnumProperty

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def getCategoriesForEnumProperty(self, context):
    """Returns a list of categories for an EnumProperty.
    
    The categories are based on the ``categories`` variable in the current namespace.
    
    If there are no categories return ('-', '-', '-').

    Args:
      context: 

    Returns:
      list: available category in the model library.

    """
    if not categories:
        return [('-',) * 3]
    return sorted([(item,) * 3 for item in categories]) 
開發者ID:dfki-ric,項目名稱:phobos,代碼行數:19,代碼來源:models.py

示例4: get_filebrowser_display_type

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def get_filebrowser_display_type(is_image=False):
    """Gets enum property for specifying display type of file browser.
    If is_image argument is not passed or is False default display type is used.

    :param is_image: flag specifying if display type shall be image preview
    :type is_image: bool
    :return: enum property of display type for Blender file browser
    :rtype: bpy.types.EnumProperty
    """

    default_value = "FILE_IMGDISPLAY" if is_image else "FILE_DEFAULTDISPLAY"

    return EnumProperty(
        items=[
            ("FILE_DEFAULTDISPLAY", "", ""),
            ("FILE_SHORTDISPLAY", "", ""),
            ("FILE_LONGDISPLAY", "", ""),
            ("FILE_IMGDISPLAY", "", "")
        ],
        default=default_value,
        options={'HIDDEN'}
    ) 
開發者ID:SCSSoftware,項目名稱:BlenderTools,代碼行數:24,代碼來源:property.py

示例5: get_sorted_list

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def get_sorted_list(cls, sort="name"):
        # Make a deep copy of the ior_values dict
        ior_values = copy.deepcopy(cls._ior_values)
        # Append a unique integer index to each tuple. The EnumProperty needs
        # this to determine a default item (index 0) when using a callback.
        # Failure to do so results in a random item becoming the default.
        ior_values[cls.default_key].append(0)
        index = 1
        for ior in ior_values:
            if ior != cls.default_key:
                ior_values[ior].append(index)
                index += 1
        # Convert the dict to a sorted list of tuples
        if sort == "value":
            index = 1
        else:
            index = 0
        preset_list = []
        for item in sorted(ior_values.items(),
                           key=lambda e: e[1][index]):
            text = "{} ({:f})".format(item[1][0], item[1][1])
            preset_list.append((item[0], text, text, item[1][2]))
        return preset_list 
開發者ID:LuxCoreRender,項目名稱:BlendLuxCore,代碼行數:25,代碼來源:ior_presets.py

示例6: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
	for cls in classes:
		try:
			bpy.utils.register_class(cls)
		except ValueError as e:
			log.warning('{} is already registered, now unregister and retry... '.format(cls))
			bpy.utils.unregister_class(cls)
			bpy.utils.register_class(cls)
	#Create uilist collections
	bpy.types.Scene.uiListCollec = CollectionProperty(type=RECLASS_PG_color)
	bpy.types.Scene.uiListIndex = IntProperty() #used to store the index of the selected item in the uilist
	bpy.types.Scene.colorRampPreview = CollectionProperty(type=RECLASS_PG_color_preview)
	#Add handlers
	bpy.app.handlers.depsgraph_update_post.append(scene_update)
	#
	bpy.types.Scene.analysisMode = EnumProperty(
		name = "Mode",
		description = "Choose the type of analysis this material do",
		items = [('HEIGHT', 'Height', "Height analysis"),
		('SLOPE', 'Slope', "Slope analysis"),
		('ASPECT', 'Aspect', "Aspect analysis")],
		update = updateAnalysisMode
		) 
開發者ID:domlysz,項目名稱:BlenderGIS,代碼行數:25,代碼來源:nodes_terrain_analysis_reclassify.py

示例7: enum_sprite_previews

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def enum_sprite_previews(self, context):
    """EnumProperty callback"""
    enum_items = []
    if context is None:
        return enum_items
    if self.coa_type == "MESH":

        # Get the preview collection (defined in register func).
        coa_pcoll = preview_collections["coa_thumbs"]
        
        #thumb_dir_path = bpy.utils.user_resource("DATAFILES","coa_thumbs")
        thumb_dir_path = os.path.join(context.user_preferences.filepaths.temporary_directory,"coa_thumbs")
        
        if os.path.exists(thumb_dir_path):
            # Scan the directory for png files
            image_paths = []
            for fn in os.listdir(thumb_dir_path):
                if fn.lower().endswith(".png") and self.name in fn:
                    image_paths.append(fn)      
            for i, name in enumerate(image_paths):
                if i < self.coa_tiles_x * self.coa_tiles_y:
                    filepath = os.path.join(thumb_dir_path, name)

                    if name in coa_pcoll:
                        thumb = coa_pcoll[name]
                    else:    
                        thumb = coa_pcoll.load(name, filepath, 'IMAGE')
                    enum_items.append((str(i), name, "", thumb.icon_id, i))
    elif self.coa_type == "SLOT":
        for i,slot in enumerate(self.coa_slot):
            if slot.mesh != None:
                img = slot.mesh.materials[0].texture_slots[0].texture.image
                icon = bpy.types.UILayout.icon(img)
                enum_items.append((str(i), slot.mesh.name, "", icon, i))
 
    return enum_items 
開發者ID:ndee85,項目名稱:coa_tools,代碼行數:38,代碼來源:ui.py

示例8: init_props

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def init_props(scene):
    scene.muv_props = MUV_Properties()
    scene.muv_uvbb_cp_size = FloatProperty(
        name="Size",
        description="Control Point Size",
        default=6.0,
        min=3.0,
        max=100.0)
    scene.muv_uvbb_cp_react_size = FloatProperty(
        name="React Size",
        description="Size event fired",
        default=10.0,
        min=3.0,
        max=100.0)
    scene.muv_uvbb_uniform_scaling = BoolProperty(
        name="Uniform Scaling",
        description="Enable Uniform Scaling",
        default=False)
    scene.muv_texproj_tex_magnitude = FloatProperty(
        name="Magnitude",
        description="Texture Magnitude.",
        default=0.5,
        min=0.0,
        max=100.0)
    scene.muv_texproj_tex_image = EnumProperty(
        name="Image",
        description="Texture Image.",
        items=get_loaded_texture_name)
    scene.muv_texproj_tex_transparency = FloatProperty(
        name="Transparency",
        description="Texture Transparency.",
        default=0.2,
        min=0.0,
        max=1.0) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:36,代碼來源:muv_props.py

示例9: reset_rna

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def reset_rna(self, callback=None):
        bpy.types.Material.ogre_parent_material = EnumProperty(
            name="Script Inheritence",
            description='ogre parent material class',
            items=self.ENUM_ITEMS,
            #update=callback
        ) 
開發者ID:OGRECave,項目名稱:blender2ogre,代碼行數:9,代碼來源:material.py

示例10: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    """TODO Missing documentation"""
    from bpy.types import WindowManager
    from bpy.props import EnumProperty

    WindowManager.mechanismpreview = EnumProperty(
        items=getMechanismListForEnumProperty, name='Mechanism'
    )
    compileMechanismList() 
開發者ID:dfki-ric,項目名稱:phobos,代碼行數:11,代碼來源:mechanisms.py

示例11: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    """TODO Missing documentation"""
    from bpy.types import WindowManager
    from bpy.props import StringProperty, EnumProperty, BoolProperty

    WindowManager.modelpreview = EnumProperty(items=getModelListForEnumProperty, name='Model')
    WindowManager.category = EnumProperty(items=getCategoriesForEnumProperty, name='Category')
    compileModelList() 
開發者ID:dfki-ric,項目名稱:phobos,代碼行數:10,代碼來源:models.py

示例12: getEnumItems

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def getEnumItems(cls):
		'''Return a list of predefined crs usable to fill a bpy EnumProperty'''
		crsItems = []
		data = cls.getData()
		for srid, name in data.items():
			#put each item in a tuple (key, label, tooltip)
			crsItems.append( (srid, name, srid) )
		return crsItems


#################
# Collection of operators to manage predefinates CRS 
開發者ID:domlysz,項目名稱:BlenderGIS,代碼行數:14,代碼來源:prefs.py

示例13: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    bpy.utils.register_module(__name__)

    # space_userprefs.py
    from bpy.props import StringProperty, EnumProperty
    from bpy.types import WindowManager

    def addon_filter_items(self, context):
        import addon_utils

        items = [('All', "All", "All Add-ons"),
                 ('User', "User", "All Add-ons Installed by User"),
                 ('Enabled', "Enabled", "All Enabled Add-ons"),
                 ('Disabled', "Disabled", "All Disabled Add-ons"),
                 ]

        items_unique = set()

        for mod in addon_utils.modules(refresh=False):
            info = addon_utils.module_bl_info(mod)
            items_unique.add(info["category"])

        items.extend([(cat, cat, "") for cat in sorted(items_unique)])
        return items

    WindowManager.addon_search = StringProperty(
            name="Search",
            description="Search within the selected filter",
            options={'TEXTEDIT_UPDATE'},
            )
    WindowManager.addon_filter = EnumProperty(
            items=addon_filter_items,
            name="Category",
            description="Filter add-ons by category",
            )

    WindowManager.addon_support = EnumProperty(
            items=[('OFFICIAL', "Official", "Officially supported"),
                   ('COMMUNITY', "Community", "Maintained by community developers"),
                   ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
                   ],
            name="Support",
            description="Display support level",
            default={'OFFICIAL', 'COMMUNITY'},
            options={'ENUM_FLAG'},
            )
    # done... 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:49,代碼來源:__init__.py

示例14: register

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def register():
    from bpy.utils import register_class
    for mod in _modules_loaded:
        for cls in mod.classes:
            register_class(cls)

    # space_userprefs.py
    from bpy.props import StringProperty, EnumProperty
    from bpy.types import WindowManager

    def addon_filter_items(self, context):
        import addon_utils

        items = [('All', "All", "All Add-ons"),
                 ('User', "User", "All Add-ons Installed by User"),
                 ('Enabled', "Enabled", "All Enabled Add-ons"),
                 ('Disabled', "Disabled", "All Disabled Add-ons"),
                 ]

        items_unique = set()

        for mod in addon_utils.modules(refresh=False):
            info = addon_utils.module_bl_info(mod)
            items_unique.add(info["category"])

        items.extend([(cat, cat, "") for cat in sorted(items_unique)])
        return items

    WindowManager.addon_search = StringProperty(
            name="Search",
            description="Search within the selected filter",
            options={'TEXTEDIT_UPDATE'},
            )
    WindowManager.addon_filter = EnumProperty(
            items=addon_filter_items,
            name="Category",
            description="Filter add-ons by category",
            )

    WindowManager.addon_support = EnumProperty(
            items=[('OFFICIAL', "Official", "Officially supported"),
                   ('COMMUNITY', "Community", "Maintained by community developers"),
                   ('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)")
                   ],
            name="Support",
            description="Display support level",
            default={'OFFICIAL', 'COMMUNITY'},
            options={'ENUM_FLAG'},
            )
    # done... 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:52,代碼來源:__init__.py

示例15: enum_previews_from_directory_items

# 需要導入模塊: from bpy import props [as 別名]
# 或者: from bpy.props import EnumProperty [as 別名]
def enum_previews_from_directory_items(self, context):
    """EnumProperty callback"""
    enum_items = []

    if context is None:
        return enum_items

    wm = context.window_manager
    
    script_file = os.path.realpath(__file__)
    dir = os.path.dirname(script_file)
    directory=os.path.join(dir,"textures_real_lights"+_)

    # Get the preview collection (defined in register func).
    pcoll = preview_collections["main"]
    
    dir_up = os.path.getmtime(directory)
    if pcoll.initiated and dir_up <= pcoll.dir_update_time:
        return pcoll.tex_previews
    pcoll.dir_update_time = dir_up
    
    pcoll.clear()

    print("Scanning directory: %s" % directory)

    if directory and os.path.exists(directory):
        # Scan the directory for png files
        image_paths = []
        for fn in os.listdir(directory):
            if os.path.splitext(fn)[1] in (".tif", ".exr", ".hdr"):
                image_paths.append(fn)

        for i, name in enumerate(image_paths):
            # generates a thumbnail preview for a file.
            filepath = os.path.join(directory, name)
            thumb = pcoll.load(filepath, filepath, 'IMAGE', True)
            basename = os.path.splitext(name)[0]
            enum_items.append((name, basename, name, thumb.icon_id, i))

    pcoll.tex_previews = enum_items
    pcoll.initiated = True
    return pcoll.tex_previews


# We can store multiple preview collections here,
# however in this example we only store "main" 
開發者ID:leomoon-studios,項目名稱:leomoon-lightstudio,代碼行數:48,代碼來源:light_preview_list.py


注:本文中的bpy.props.EnumProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。