1
$\begingroup$

I am trying to create a simple menu with three fields below each other. The description on the left, the clickable part on the right. However, blender makes my layout explode!

This is what I think it should look like (done in MS paint): This is what I think it should look like

This is what it actually ends up looking like (for some reason the fields are "staggered"): This is what it looks like

This is what I have tried:

import bpy

class MyMenu(bpy.types.Menu):
    bl_idname = "OBJECT_MT_my_menu"
    bl_label = "my_menu"

    def draw(self, context):
        layout = self.layout
        col = layout.column()
        col.prop(context.object, 'name', text='First field - object name')
        col.prop(context.object, 'parent', text='Second field - object parent')
        col.prop(context.object, 'location', text='Third field - object location')

class OpenMyMenu(bpy.types.Operator):
    bl_idname = "view3d.open_my_menu"
    bl_label = "Open My Menu"
    bl_options = {'REGISTER'}

    def execute(self, context):
        bpy.ops.wm.call_menu(name=MyMenu.bl_idname)
        return {'FINISHED'}

bpy.utils.register_class(MyMenu)
bpy.utils.register_class(OpenMyMenu)

Why does blender explode my layout like this and how can it be fixed? I have tried messing around with rows and columns and alignment, but it always ends up looking like this.

$\endgroup$
1
  • $\begingroup$ Menu layouts are mostly for operators, and in some cases checkboxes. Consider using a popup $\endgroup$
    – batFINGER
    Commented Sep 18, 2018 at 11:46

0

You must log in to answer this question.

Browse other questions tagged .