Post #2869: : post_02872
🏷️ Tags
pie-menu hotkeys advanced solved
⚙️ Related PME Features
- Pie Menu Editor
- Python Scripting
💬 Content
Flattiefolks:
Is “Pie Menu Editor” capable of switching between pre-created custom workspaces,
in order to switch between different workspaces more easily via pie menus than with
tedious default top bar side scrolling?
Yes, you can do this in PME.
But in your case it’s better to code some custom search-operator, which opens a search popup:
import bpy
class WORKSPACE_OT_select(bpy.types.Operator):
bl_idname = "workspace.select"
bl_label = "Select Workspace"
bl_description = "Select workspace"
bl_property = "workspace"
enum_items = None
def get_items(self, context):
if WORKSPACE_OT_select.enum_items is None:
enum_items = []
for w in bpy.data.workspaces:
identifier, name, description = \
w.name, w.name, w.name
if context.workspace.name == identifier:
name += "|Active"
enum_items.append((
identifier,
name,
description))
WORKSPACE_OT_select.enum_items = enum_items
return WORKSPACE_OT_select.enum_items
workspace = bpy.props.EnumProperty(items=get_items)
def execute(self, context):
if not self.workspace or self.workspace not in bpy.data.workspaces:
return {'CANCELLED'}
context.window.workspace = bpy.data.workspaces[self.workspace]
return {'FINISHED'}
def invoke(self, context, event):
WORKSPACE_OT_select.enum_items = None
context.window_manager.invoke_search_popup(self)
return {'FINISHED'}
def register():
bpy.utils.register_class(WORKSPACE_OT_select)
def unregister():
bpy.utils.unregister_class(WORKSPACE_OT_select)
if __name__ == "__main__":
register()
# test call
bpy.ops.workspace.select('INVOKE_DEFAULT')
You can test this operator in Blender Text Editor.
Copy, paste and press Run Script button.
Flattiefolks:
Can I save & export custom pie menus created with “Pie Menu Editor” and distribute them for free to people who didn’t purchase and install “Pie Menu Editor”?
No, PME doesn’t support this.
❤️ 4 likes