Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/wm.py
| Show First 20 Lines • Show All 2,329 Lines • ▼ Show 20 Lines | class WM_OT_tool_set_by_name(Operator): | ||||
| """Set the tool by name (for keymaps)""" | """Set the tool by name (for keymaps)""" | ||||
| bl_idname = "wm.tool_set_by_name" | bl_idname = "wm.tool_set_by_name" | ||||
| bl_label = "Set Tool By Name" | bl_label = "Set Tool By Name" | ||||
| name = StringProperty( | name = StringProperty( | ||||
| name="Text", | name="Text", | ||||
| description="Display name of the tool", | description="Display name of the tool", | ||||
| ) | ) | ||||
| space_type = EnumProperty( | |||||
| name="Type", | |||||
| items=tuple( | |||||
| (e.identifier, e.name, "", e. value) | |||||
| for e in bpy.types.Space.bl_rna.properties["type"].enum_items | |||||
| ), | |||||
| default='EMPTY', | |||||
| ) | |||||
| def execute(self, context): | def execute(self, context): | ||||
| from bl_ui.space_toolsystem_common import activate_by_name | from bl_ui.space_toolsystem_common import activate_by_name | ||||
| if activate_by_name(context, context.space_data.type, self.name): | space_type = self.space_type | ||||
| if space_type == 'EMPTY': | |||||
| space_type = context.space_data.type | |||||
| if activate_by_name(context, space_type, self.name): | |||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| else: | else: | ||||
| self.report({'WARNING'}, f"Tool {self.name!r} not found.") | self.report({'WARNING'}, f"Tool {self.name!r} not found.") | ||||
| return {'CANCELLED'} | return {'CANCELLED'} | ||||
| classes = ( | classes = ( | ||||
| BRUSH_OT_active_index_set, | BRUSH_OT_active_index_set, | ||||
| ▲ Show 20 Lines • Show All 54 Lines • Show Last 20 Lines | |||||