magicgui icon indicating copy to clipboard operation
magicgui copied to clipboard

Bug: Widget `name` in containers can be confusing if conflicting with `Widget` attributes

Open tlambert03 opened this issue 4 years ago • 0 comments

Describe the bug Container Widgets allow convenient subwidget access using attribute access... but this can lead to unexpected results if a widget name clashes with an attribute on Widget. __getitem__ still works, but we should catch these name collisions and provide a more obvious warning

In [1]: from magicgui.widgets import Container, LineEdit

In [2]: edit = LineEdit(name='name', value='hi')

In [3]: container = Container(widgets=[edit])

In [4]: container.name
Out[4]: ''

# but this works
In [5]: container['name']
Out[5]: LineEdit(value='hi', annotation=None, name='name')

tlambert03 avatar Aug 23 '22 17:08 tlambert03