Skip to content

Container(widgets=[...]) and Container.append(...) produce different label alignment #729

@commongeek

Description

@commongeek

I noticed that creating a Container with the widgets constructor argument produces different label/control alignment than creating an empty Container and adding the same widgets with append().

Minimal repro:

from magicgui.widgets import Container, LineEdit, SpinBox

via_constructor = Container(
    widgets=[
        LineEdit(label='Name', value='Ada'),
        SpinBox(label='Very long label', value=3),
    ]
)

via_append = Container()
via_append.append(LineEdit(label='Name', value='Ada'))
via_append.append(SpinBox(label='Very long label', value=3))

Container(widgets=[via_constructor, via_append]).show(run=True)

Expected behavior
Both containers should render with the same label/control alignment, since the widgets are equivalent and only the construction method differs.

Actual behavior
The container created with Container(widgets=[...]) renders differently from the one populated with append(). In my case, the append() version aligns labels and controls correctly, while the constructor version does not.

Image

Environment
magicgui version: 0.10.2
backend: PySide6
OS: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions