Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bpy_types.py
| Show First 20 Lines • Show All 1,068 Lines • ▼ Show 20 Lines | def draw_preset(self, _context): | ||||
| - preset_subdir (string) | - preset_subdir (string) | ||||
| Optionally: | Optionally: | ||||
| - preset_add_operator (string) | - preset_add_operator (string) | ||||
| - preset_extensions (set of strings) | - preset_extensions (set of strings) | ||||
| - preset_operator_defaults (dict of keyword args) | - preset_operator_defaults (dict of keyword args) | ||||
| """ | """ | ||||
| import bpy | import bpy | ||||
| from bpy.app.translations import pgettext_iface as iface_ | |||||
| ext_valid = getattr(self, "preset_extensions", {".py", ".xml"}) | ext_valid = getattr(self, "preset_extensions", {".py", ".xml"}) | ||||
| props_default = getattr(self, "preset_operator_defaults", None) | props_default = getattr(self, "preset_operator_defaults", None) | ||||
| add_operator = getattr(self, "preset_add_operator", None) | add_operator = getattr(self, "preset_add_operator", None) | ||||
| self.path_menu( | self.path_menu( | ||||
| bpy.utils.preset_paths(self.preset_subdir), | bpy.utils.preset_paths(self.preset_subdir), | ||||
| self.preset_operator, | self.preset_operator, | ||||
| props_default=props_default, | props_default=props_default, | ||||
| filter_ext=lambda ext: ext.lower() in ext_valid, | filter_ext=lambda ext: ext.lower() in ext_valid, | ||||
| add_operator=add_operator, | add_operator=add_operator, | ||||
| display_name=lambda name: bpy.path.display_name(name, title_case=False) | display_name=lambda name: iface_( | ||||
| bpy.path.display_name(name, title_case=False)) | |||||
| ) | ) | ||||
| @classmethod | @classmethod | ||||
| def draw_collapsible(cls, context, layout): | def draw_collapsible(cls, context, layout): | ||||
| # helper function for (optionally) collapsed header menus | # helper function for (optionally) collapsed header menus | ||||
| # only usable within headers | # only usable within headers | ||||
| if context.area.show_menus: | if context.area.show_menus: | ||||
| # Align menus to space them closely. | # Align menus to space them closely. | ||||
| ▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines | |||||