Is it possible to add submenu (from another custom class) in pie menu is a such way as to make it always expanded (without howering over it). Or maybe it possible with popup menu as submenu? (For example, there is “Expand Popup Dialog” checkbox in Pie Menu Editor addon).
And second question is how to insert panels in pie menu? Again, it is possible with Pie Menu Editor but I want to know how do it by myself, without addons.
import bpy
from bpy.types import Menu, Operator
class CUSTOM_MT_menu(Menu):
bl_label = "Main Menu"
bl_idname = "CUSTOM_MT_menu"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
pie.menu("CUSTOM_MT_submenu", text='SubMenu')
pie.operator("object.custom_operator", text='Operator')
col = pie.column()
col.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
col.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
col.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
class CUSTOM_MT_submenu(Menu):
bl_label = "Sub Menu"
bl_idname = "CUSTOM_MT_submenu"
def draw(self, context):
layout = self.layout
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
class CUSTOM_OT_operator(Operator):
bl_idname = "object.custom_operator"
bl_label = "Operator"
def execute(self, context):
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
return wm.invoke_props_dialog(self, width=70)
def draw(self, context):
layout = self.layout
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
layout.operator("mesh.primitive_cube_add", text = "Cube", icon = "MESH_CUBE")
classes = (
CUSTOM_MT_menu,
CUSTOM_MT_submenu,
CUSTOM_OT_operator
)
register, unregister = bpy.utils.register_classes_factory(classes)
if __name__ == "__main__":
register()
bpy.ops.wm.call_menu_pie(name="CUSTOM_MT_menu")