Layout Error?

Hi there,
I have some menu and panels, that works fine,
now i made a new menu and i am completely lost .

Wherever i call this menu, it always have the wrong layout.
How this is possible?

Edit: I found many posts around about layout,
Some of them i dont know how make them work, like this


only the last seems to work, But still the layour is pretty weird,
Why the labels are not all equally wided?
    def draw(self, context):
        layout = self.layout
        col = layout.column_flow(columns=3, align=False)
        col.label(text="row0-col0", icon='WORLD_DATA')
        col.label(text="row0-col1!", icon='WORLD_DATA')
        col.label(text="row1-col0!", icon='WORLD_DATA')
        col.label(text="row1-col1!", icon='WORLD_DATA')
        col.label(text="row2-col2!", icon='WORLD_DATA')  
        col.label(text="row2-col2!", icon='WORLD_DATA')

Thanks for reply,
yes the column_flow will at least equally place the buttons,

I post here another screen of the behaviour of the row()
The same command apply to the panel on the left, will shrink 3 operator in 1 column
Why the menu instead will place the 3 operators in row , creating new columns?
The goal is to have the menu like the panel, what am i missing?


1 Like

ok so a menu is working as a flow so using row then column won’t work as in a panel.
so to have exactly same menu that for a panel you can run a floating panel from an operator (in another menu or a shortcut. like I did there

bl_info = {
    "name": " Aaaa",
    "author": "name",
    "version": (1, 0, 0),
    "blender": (2, 80, 0),
    "location": "View3D",
    "category": "Menu"
}
    
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()

notice I’m not showing the menu in properties panel to not overload it.

1 Like