What would be the nicest way to code(in Python) a pie menu in Blender 2.79 or 2.8, that would have another menu as an addition to the standard 8 pie menu choices?
After playing with it for some time I found that this kind of works:
import bpy
from bpy.types import Menu
class VIEW3D_PIE_template(Menu):
bl_label = "Some Pie Menu"
def draw(self, context):
layout = self.layout
pie = layout.menu_pie()
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.operator("mesh.primitive_cube_add")
pie.separator()
pie.separator()
gap = pie.column()
gap.separator()
gap.separator()
gap.separator()
gap.separator()
gap.separator()
gap.separator()
gap.separator()
menu = gap.box()
menu.scale_x = 2.5
menu.operator("mesh.primitive_monkey_add")
menu.operator("mesh.primitive_monkey_add")
def register():
bpy.utils.register_class(VIEW3D_PIE_template)
def unregister():
bpy.utils.unregister_class(VIEW3D_PIE_template)
if __name__ == "__main__":
register()
bpy.ops.wm.call_menu_pie(name="VIEW3D_PIE_template")
I wonder if there is a nicer way. This feels 'hacky' and it would be nice to have a menu that would have expandable sub-menus if that is possible at all. I realize that might be too much to wish for... Any advice?
gap.scale_y = 5.0
to create the distance, but this could mess with spacing of anything put after thegap.box()
item in the column. So multiple separators are imho the best to make the space, I would not worry about it. You can add some comments in the code to make it feel less hacky, like# spacing between pie and column menu
followed by the separators. $\endgroup$draw_gap(self, layout, count=7):
method will "clean" the code up somewhat. $\endgroup$