couldn't be any simpler, this includes how to use icons in the EnumProperty - this can reduce the verbosity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from bpy.types import Menu | |
class VIEW3D_PIE_SV_ops(bpy.types.Operator): | |
bl_idname = "nodes.pie_menu_enum" | |
bl_label = "Add Quick Node" | |
mode_options = [ | |
("option1", "option1", "", "CURVE_DATA", 0), | |
("option2", "option2", "", "", 1), | |
("option3", "option3", "", "", 2) | |
] | |
selected_mode = bpy.props.EnumProperty( | |
items=mode_options, | |
description="offers....", | |
default="option1" | |
) | |
def execute(self, context): | |
print('added ', self.selected_mode) | |
return {'FINISHED'} | |
class VIEW3D_PIE_template(Menu): | |
# label is displayed at the center of the pie menu. | |
bl_label = "Select Mode" | |
def draw(self, context): | |
layout = self.layout | |
pie = layout.menu_pie() | |
pie.operator_enum("nodes.pie_menu_enum", "selected_mode") | |
def register(): | |
bpy.utils.register_module(__name__) | |
def unregister(): | |
bpy.utils.unregister_module(__name__) | |
if __name__ == "__main__": | |
register() | |
bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template") |