Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bpy_types.py
| Show First 20 Lines • Show All 922 Lines • ▼ Show 20 Lines | def path_menu(self, searchpaths, operator, *, | ||||
| files.sort() | files.sort() | ||||
| col = layout.column(align=True) | col = layout.column(align=True) | ||||
| for f, filepath in files: | for f, filepath in files: | ||||
| # Intentionally pass the full path to 'display_name' callback, | # Intentionally pass the full path to 'display_name' callback, | ||||
| # since the callback may want to use part a directory in the name. | # since the callback may want to use part a directory in the name. | ||||
| row = col.row(align=True) | row = col.row(align=True) | ||||
| name = display_name(filepath) if display_name else bpy.path.display_name(f) | name = display_name(filepath) if display_name else bpy.path.display_name(f) | ||||
natecraddock: Here the first `display_name` function might not have a title_case argument because it is a… | |||||
| props = row.operator( | props = row.operator( | ||||
| operator, | operator, | ||||
| text=name, | text=name, | ||||
| translate=False, | translate=False, | ||||
| ) | ) | ||||
| if props_default is not None: | if props_default is not None: | ||||
| for attr, value in props_default.items(): | for attr, value in props_default.items(): | ||||
| Show All 37 Lines | def draw_preset(self, _context): | ||||
| 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) | |||||
Done Inline ActionsThis comment isn't critical, but a simpler way would be to pass in a lambda for display_name (like for filter_ext) that calls bpy.path.display_name with title_case=True. Then you don't even need to add an extra argument to path_menu. natecraddock: This comment isn't critical, but a simpler way would be to pass in a lambda for display_name… | |||||
| ) | ) | ||||
| @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 66 Lines • Show Last 20 Lines | |||||
Here the first display_name function might not have a title_case argument because it is a callback function passed in, so that should be removed.