I have created this simple menu so you can test it. This will pop up with Y
import bpy
addon_keymaps = {}
class CUSTOM_MT_PANEL(bpy.types.Menu):
bl_idname = "CUSTOM_MT_PANEL"
bl_label = "Custom Menu"
def draw(self, context):
layout = self.layout.column_flow(columns=1)
layout.operator_context = "INVOKE_DEFAULT"
op = layout.operator('mesh.primitive_cube_add', text='Add Cube', icon='CUBE')
op = layout.operator('mesh.primitive_uv_sphere_add', text='Add Sphere', icon='SPHERE')
op = layout.operator('mesh.primitive_ico_sphere_add', text='Add Ico Sphere', icon='MESH_ICOSPHERE')
op = layout.operator('mesh.primitive_torus_add', text='Add Torus', icon='MESH_TORUS')
op = layout.operator('mesh.primitive_monkey_add', text='Add Monkey', icon='MONKEY')
layout.menu('SUB_MT_MENU')
class SUB_MT_MENU(bpy.types.Menu):
bl_idname = "SUB_MT_MENU"
bl_label = "Curves"
def draw(self, context):
layout = self.layout.column_flow(columns=1)
layout.operator_context = "INVOKE_DEFAULT"
op = layout.operator('curve.primitive_bezier_curve_add', text='Add Bezier', icon='IPO_BEZIER')
op = layout.operator('curve.primitive_bezier_circle_add', text='Add Circle', icon='CURVE_NCIRCLE')
op = layout.operator('curve.primitive_nurbs_path_add', text='Add Path', icon='CURVE_PATH')
def register():
bpy.utils.register_class(CUSTOM_MT_PANEL)
bpy.utils.register_class(SUB_MT_MENU)
kc = bpy.context.window_manager.keyconfigs.addon
km = kc.keymaps.new(name='3D View', space_type='VIEW_3D')
kmi = km.keymap_items.new('wm.call_menu', 'Y', 'PRESS')
kmi.properties.name = 'CUSTOM_MT_PANEL'
addon_keymaps['EA098'] = (km, kmi)
def unregister():
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
for km, kmi in addon_keymaps.values():
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(CUSTOM_MT_PANEL)
bpy.utils.unregister_class(SUB_MT_MENU)
if __name__ == "__main__":
register()
```
ui.copy_data_path_button
(Custom ui operators) $\endgroup$