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

Custom Widget docs: Adding a list of variable names to avoid #3159

Open
jasonho-lynx opened this issue Mar 12, 2021 · 2 comments
Open

Custom Widget docs: Adding a list of variable names to avoid #3159

jasonho-lynx opened this issue Mar 12, 2021 · 2 comments
Labels
Custom Widget Issues related to using ipywidgets as a framework for custom widgets docs

Comments

@jasonho-lynx
Copy link

Link: https://github.com/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20Custom.ipynb

Problem

Hi - would like to suggest adding some detail in the documentation relating to widget variable name collisions.

Using certain widget variables can cause errors. In my case, I used 'style', which returned the following error from DOMWidgetView:

Uncaught (in promise) TypeError: Cannot read property 'then' of undefined
    at l.t.create_view (manager-base.js:85)
    at EmailView.e.create_child_view (widget.js:604)
    at widget.js:774

Looking into the widget.ts file, it does show that the 'style' variable is already used there for DOMWidgetView.

Steps I took to get this error message:

  1. Followed the Custom Widget tutorial, but replaced every occurrence of the value variable with style instead.
  2. In Jupyter Notebook, instantiated the widget using email = Email(value='john.doe@domain.com', disabled=False) and email
  3. F12 to see the error in console

It didn't seem to affect functionality.

Suggested Improvement

One solution might be to add into the documentation a list of some variables to avoid using because of potential collisions.

@ianhi
Copy link
Contributor

ianhi commented Mar 12, 2021

Thanks for bringing this up @jasonho-lynx - I think adding more docs for this is great idea. Would you like to make a PR? It could either go into the existing tutorial or into a new page that would have miscellaneous information for making a custom widget.

We could also consider changing the name like we did in #2944 and #3122

@jasonho-lynx
Copy link
Author

Sure, will take a stab at it when I have the time!

@ianhi ianhi added the Custom Widget Issues related to using ipywidgets as a framework for custom widgets label Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Custom Widget Issues related to using ipywidgets as a framework for custom widgets docs
Projects
None yet
Development

No branches or pull requests

2 participants