Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"bind" incompatible with Container-like ValueWidgets #661

Open
hanjinliu opened this issue Jul 30, 2024 · 2 comments
Open

"bind" incompatible with Container-like ValueWidgets #661

hanjinliu opened this issue Jul 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@hanjinliu
Copy link
Contributor

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
@hanjinliu hanjinliu added the bug Something isn't working label Jul 30, 2024
@tlambert03
Copy link
Member

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

@hanjinliu
Copy link
Contributor Author

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 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants