Here is the code:
import bpy class BlablaMenu(bpy.types.Menu): bl_label = "blabla" bl_idname = "VIEW3D_MT_blabla_menu" def draw(self, context): layout = self.layout layout.operator("object.text_add") def draw_item(self, context): layout = self.layout layout.menu(BlablaMenu.bl_idname) def register(): bpy.utils.register_class(BlablaMenu) bpy.types.VIEW3D_HT_header.prepend(draw_item) def unregister(): bpy.types.VIEW3D_HT_header.remove(draw_item) bpy.utils.unregister_class(BlablaMenu) if __name__ == "__main__": register()
I am aware of similar questions, but the answers are outdated. I also tried to understand how RetopoFlow and Boxcutter are solving this problem, but I can't find the code that draws those menus in order to reverse engineer it. Another approach would be to remove all the menus, create my own and re-create te deleted menus, but I don't know how to do that either.
Thank you and happy new year!