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

Errors with "controls" argument of @interact #579

Open
Keanel-19 opened this issue Dec 21, 2023 · 2 comments
Open

Errors with "controls" argument of @interact #579

Keanel-19 opened this issue Dec 21, 2023 · 2 comments

Comments

@Keanel-19
Copy link

Keanel-19 commented Dec 21, 2023

There is multiple errors with the controls argument of @interact.

To use it, the decorated function must have a **kargs argument so it can pass the controls.

@interact(controls=[("b",Button("a"))])
def f(**kargs):
    pass

This code throw an error because it try to pass the proxy to kargs, because it's the first argument of f and doesn't have a default value. But in this case f doesn't take any positional argument :

TypeError: f() takes 0 positional arguments but 1 was given

I can resolve it by adding any argument before **kargs (any control or an argument for the proxy):

@interact(controls=[("b",Button("a"))])
def f(proxy, **kargs):
    pass

In this case, it doesn't throw any error but sagecell add an input control with label kargs
image

For now I just do this:

@interact(controls=[("b",Button("AA"))])
def f(proxy,**kargs):
    if getattr(proxy,"kargs"):
        del proxy.kargs
@novoselt
Copy link
Member

To clarify - is this new behaviour, i.e. things were working for you before, but got broken now, or have you just discovered it? What API are you trying to follow?

@Keanel-19
Copy link
Author

I discovered it by following the docstrings in the source file of interacts. I didn't find a better doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants