pyapp-kit/magicgui

"bind" incompatible with Container-like ValueWidgets

Opened this issue · 2 comments

Describe the bug

Cannot use "bind" option with ListEdit and TupleEdit in the main branch version.
See #658 (comment)

To Reproduce

from magicgui import magicgui

@magicgui(x={"bind": [1]})
def func(x: list[int]):
    print(x)

func.show(True)
TypeError: ListEdit got an unexpected keyword argument: bind

Expected behavior
"bind" should be processed similarly as other value widgets.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: Windows
  • backend: PyQt5 5.15.10
  • magicgui version 0.8.4.dev12+g1479122

The proper fix here is to create some sort of value widget container widget subclass. I think the list widget and tuple widget were the first (only?) widgets that used Container but also implemented a duck-type ValueWidget interface (but without actually subclassing). So if you want bind on those widgets, we should go back and create a proper value/container merge

RangeEdit, SliceEdit and FileEdit also inherits Container. I agree that these widgets should subclass ValueWidget at some points. In that sense, this issue will be a part of #372 .
I tried multiple inheritance and failed before, so I think we need a small refactoring of the widget classes. I will send a PR in a few day 😃