1_conscience_0_dimen Answered me a solution.
Basically the layout work differently but
we can call the menu in this different way to keep the right layout.
He posted me this script that show the behaviour.
You can see it in the link above too
import bpy
###Panel
class PANEL_PT_Menu(bpy.types.Panel):
bl_label = "panel menu"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "0data" # to hide it. bl_context = "object" to show it in props
bl_options = {'DEFAULT_CLOSED'}
def draw(self, context):
layout = self.layout
layout.label(text="The Menu you want as a panel")
####call as an operator
class SimpleOperator(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def execute(self, context):
bpy.ops.wm.call_panel(name='PANEL_PT_Menu', keep_open=True)
return {'FINISHED'}
addon_keymaps = []
def register():
bpy.utils.register_class(PANEL_PT_Menu)
bpy.utils.register_class(SimpleOperator)
wm = bpy.context.window_manager
if wm.keyconfigs.addon: #### call it from a key
km = wm.keyconfigs.addon.keymaps.new(name = '3D View Generic', space_type = 'VIEW_3D')
kmi = km.keymap_items.new(idname='wm.call_panel', type='Q', value='PRESS', alt=True)
kmi.properties.name = "PANEL_PT_Menu"
addon_keymaps.append((km, kmi))
def unregister():
bpy.utils.unregister_class(PANEL_PT_Menu)
bpy.utils.unregister_class(SimpleOperator)
wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
if kc:
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
register()
# test call
bpy.ops.object.simple_operator()