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

Support an "eval" attribute to evaluate widget values in @interact #724

Closed

Conversation

jdemeyer
Copy link
Contributor

Let W be a Text widget (or another widget, but Text is a natural use case). If that is used for an interactive (@interact) function, the function receives the text from the input box, i.e. W.value as a string. I propose to support an additional evaluation step such that the interactive function could receive f(W.value) as argument for some callable f.

In the current implementation, this is done with a W.eval attribute. If that attribute exists, then W.eval(W.value) is passed to the interactive function.

The current branch deals with the internal implementation only. At this point, there is no clean user-interface for this (you have to manually set W.eval = f or define a custom widget type with an eval attribute), but that can easily be added later. I also want to avoid bikeshedding about the user-interface, I wanted feedback about the general idea first.

Context: this is to support analogous functionality from SageNB to help with OpenDreamKit/OpenDreamKit#94.

@SylvainCorlay
Copy link
Member

Is this a public API at the moment in Sage?

@jdemeyer
Copy link
Contributor Author

Is this a public API at the moment in Sage?

Yes, it is public: https://github.com/sagemath/sagenb/blob/master/sagenb/notebook/interact.py#L2758

In SageNB, the attribute is called type and it behaves differently from the eval I am proposing here. However, the SageNB type can easily be implemented using this eval.

@SylvainCorlay
Copy link
Member

ok although it is surprising to have to reserve an attribute name like eval on all widgets that can be used with interact.

@jdemeyer
Copy link
Contributor Author

Hang on, I'll propose a slightly different API.

@jdemeyer
Copy link
Contributor Author

I think that #725 is a better idea.

@jdemeyer jdemeyer closed this Aug 19, 2016
@jasongrout jasongrout added this to the Reference milestone Nov 17, 2017
@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 9, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants