-
Notifications
You must be signed in to change notification settings - Fork 950
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
Make widgets render using output areas in classic notebook. #1274
Conversation
@jasongrout Let me know if you have any questions about this stuff 👌 |
Thanks! I'm working through it right now. You may notice that I'm using a slightly different approach (I think it's a bit cleaner) to get the output area, etc. |
(for example, I'm directly requiring the output area, and using the output area prototype to register the mime type, rather than searching for an instance among the cells.) |
widgetsnbextension/src/extension.js
Outdated
@@ -46,7 +50,7 @@ var handle_cell = function(cell) { | |||
} | |||
}; | |||
|
|||
function register_events(Jupyter, events) { | |||
function register_events(Jupyter, events, outputarea) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasongrout Yep, this is cleaner. Before we unwebpackified the notebook, doing this didn't work. I will update the mimerender extensions to reflect this 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are other kludgy workarounds I can now delete because we don't have webpack too, like https://github.com/jupyter-widgets/ipywidgets/blob/master/widgetsnbextension/src/widget_output.js#L93
CC @SylvainCorlay, @maartenbreddels - it would be great if someone looked at/tested this out too, to see what I might have missed. |
Any idea of the issue raised here (about Output not syncing is related to, or fixed by this) #1232 |
Note to self: @gnestor's clearing function is at https://github.com/jupyterlab/jupyterlab_geojson/blob/master/nbextension/src/renderer.js#L21, triggered at https://github.com/jupyterlab/jupyterlab_geojson/blob/master/nbextension/src/renderer.js#L71. @gnestor - why did you also handle the output_added.OutputArea event? |
Do we have a test for the _view_count that would have failed here? |
Do you mean a unittest? Or sth automated? Or you mean just an example to demonstrate it? |
Btw, for ipyvolume, I've started doing testing in the notebook, as an integration test. Do you have experience or know someone who knows how to set up a full blown test with headless browser etc? Would be nice to automate integration tests. |
CC @blink1073 - I think JLab probably currently has the nicest infrastructure for (Javascript) testing currently. At various times, we've had headless browser testing for widgets using CasperJS. We don't have a good story for widgets right now. |
This almost calls the The only cases I've seen where something messes up now is something like this: from ipywidgets import *
out = Output()
x = IntSlider()
out with out:
display(x)
display(x) x._view_count returns 1 when it should return 2, and then evaluating the last two cells again we get |
Okay, the last commit takes care of clearing an output area. However, it doesn't address the problem of the first _view_count returning 1. Not sure what's happening there yet. |
…ple widgets in a cell.
See jupyter-widgets#1275 for bringing this back in a more general way.
@maartenbreddels - okay, _view_count looks like it is updating correctly now. It required a few fixes to the recent syncing, so I made those PRs first, and then rebased this on the current master. I think this is ready to be reviewed. |
Feedback from @maartenbreddels:
|
I don't have time to look into it now, but for the record, it seems like if a list of buffers is send, they are all the same. |
Ok, sorry for the noise, that was a bug in ipyvolume. |
The sync messages weren’t getting sent because the status handler was never getting called, which mean that once one message was sent and declared pending, we never realized when that message had been processed.
This depends on jupyter/notebook#2411 to get all the corner cases. We left in various other event triggers to cover most cases even without that PR.
@maartenbreddels - the output widget view counts should be fixed now, and if you run jupyter/notebook#2411, the view count should now be updated even if an empty cell is run. |
This is work towards fixing #1272, and makes the rendering consistent between jupyterlab and the classic notebook.
Essentially, this gets rid of the special widget area above cells, and instead renders widgets using the widget display_data output messages.
This also finishes fixing #1237.