-
Notifications
You must be signed in to change notification settings - Fork 294
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
Scripts sources related to custom IPyWidgets not loaded #10319
Comments
This is the my project(a ipynb file).Since i cannot upload it due to limit of github, i changed it to txt. |
thanks for the repro example. Confirmed that the output is blank in vscode. |
Today I tried much more simple code:
“ |
Any relation with #6054? |
VS code doesn't render your output in the same DOM as the rest of the notebook. Output is in its own iframe. The javascript you have there destroys the DOM of the iframe so that it has just 'hello world' in it, making the rendering logic for the rest of the output broken. The DOM that jupyter has is not intended to be the same as the DOM we have in VS code. There's no way it would ever be, so you'll have to be careful what you do in your script code. You might look at what standard widgets do (if you're working on a widget). Loading a script straight into an output is not really the recommended way to get a script to load. The script will fail to run the next time you execute the cell. |
@rchiodo Thanks for your reply. I am new to using jupyter in vscode. Can you give me an example of correctly using %%javascript in jupyter-vscode? |
%%javascript doesn't really work in VS code. We don't support all of the implicit properties that are available in a jupyter notebook. However you could follow the directions here if you want a python backend: IPyWidgets do work in VS code. |
I read that documentation. However i think it requires me to write my project as a package? Can i do everything in a single ipynb? |
Possibly but it would be extremely difficult. It'd be much easier to write a python module with the js files on disk. |
@rchiodo Today I ran the example provided by https://github.com/jupyter-widgets/widget-ts-cookiecutter (which is the way recommended by the website you suggested me to visit--https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Custom.html). I wrapped the example(I did not add any code) in a package as instructed, and it worked in jupyter notebook in edge. However, for vscode it is still blank. So I think the problem might be the internal mechanism vscode communicate with jupyter...(not problem with %%javascript) |
@dentistfrankchen thanks for providing the detailed explanation and code sample, I have come across a similar issue recently and have a fix for this, it is infact similar to other widget issues where we don't load the resources correctly. |
@DonJayamanne I appreciate your reply and thank you for your contribution for this project, which helps thousands of people who are doing data mining like me. I am still waiting to see the problem getting solved, since I need to wait for the next version of extension to release. Keep contact. |
@dentistfrankchen Also, if you want to generate some HTML or run some JS I'd try the following:
Even though the sample your provided might seem to work in Jupyter, that completely breaks the UI. Hence its not really a valid use case of such code. I'd change to as provided above.
Another sample is to run two cells:
|
Closing this issue as fixed, as part of #10459 |
I verified that
works
returns with error
or sometimes runs forever.
returns error Marking as verified, @DonJayamanne please check if the other errors are expected |
Recently i am trying to custom widget that contains javascript using ipywidget.However my project does not render the result as a jupyter notebook does. My widget cannot be displayed.
The text was updated successfully, but these errors were encountered: