# Fighting split col and aligning row content

I am really struggling with horizontal alignments.

Look at lower right image example.

Layer + Parent are in one column and a split function defines the width of the next column that contains the layer and parent UI elements.

The problem is that this way the row like horizontal alignment is off. Parent text is higher than the parent UI element.

I tried different row ideas but nothing worked. To my frustration in the upper right corner the parent UI is drawn on the left side while the layer element is on the right side. What causes this?

So this is what I try to do. Lets say 30/70 column spacing and the content aligned along their top edge

The % value should be global so I have to adjust it once and the layer + parent UI will be stretched along the length.

Two approaches.

not pixel accurate, but less code.

c = layout.column()
row = c.row()
split = row.split(percentage=0.3)
c = split.column()
c.label("Layers")
split = split.split()
c = split.column()
c.prop(obj, "layers", text="")

c = layout.column(align=True)
c.prop(obj, "parent", text="Parent")


Pixel perfect but a little convoluted!

c = layout.column()
row = c.row()
split = row.split(percentage=0.3)
c = split.column()
c.label("Layers")
split = split.split()
c = split.column()
c.prop(obj, "layers", text="")

c = layout.column()
row = c.row()
split = row.split(percentage=0.3)
c = split.column()
c.label("Parent")
split = split.split()
c = split.column()
c.prop(obj, "parent", text="")


The second version can be restated using a function, there's a lot of repetition, and you might want to do the same for more properties..

    def draw_props(labelname, propname):
c = layout.column()
row = c.row()
split = row.split(percentage=0.3)
c = split.column()
c.label(labelname)
split = split.split()
c = split.column()
c.prop(obj, propname, text="")

draw_props("Layers", "layers")
draw_props("Parent", "parent")

• Ah you confirmed my opinion that you cannot do that with one percentage call. Would that not be possible to define the number as a global one so each percentage could fetch the number? – Claas Kuhnen Jan 5 '16 at 23:10
• you can make a function inside the draw function (nested function). I 've done that on many occasion to simplify my UI code. Else you are bound by the Blender layout – zeffii Jan 5 '16 at 23:18