-
Notifications
You must be signed in to change notification settings - Fork 949
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
Button callbacks don't work on JupyterLab? #2380
Comments
They do work but print statements are not displayed. Output streams must be captured with an output widget. |
Is this by design, or not yet implemented. Which behavior in this case is the right one?
I ask because I'm also implementing ipywidget support for CoCalc, and I have to decide which choice to follow. |
Nobody responded (ping: @jasongrout ?). My testing suggests the semantics in Jupyter classic is that if there is an output IOPUB message but no Output widget capturing it, and no cell is being explicitly executed, then the cell whose output contains the widget that caused this message gets the output appended. More precisely, the output messages has parent_header.msg_id equal to the msg_id of the comm state update message that caused these output messages to appear. (I would have to add some info somewhere about which view caused the frontend model to change in order to know where to put the output. That sounds difficult, but possible.) I'm going to leave this for after my first ipywidgets release. However, I would like to know -- in a perfect world -- which behavior (A or B) is officially right, and which is a bug? |
I'm guessing B is a bug and A is right, because actual users would be more "surprised" by B than A, as evidenced by this issue being opened. Also, just silently ignoring output with no error message is definitely not desirable... and it's even in the docs... |
A is the behavior in Jupyter classic, enabled by a hack in the classic notebook. B is the behavior we moved to in JupyterLab (as "cleaner" behavior). We actually moved classic to B (I think in ipywidgets 7), but then re-enabled the hack later. The problem is actually a more general problem than widgets - it's what to do about output stemming from a comm message, where there may not be any clear place to put the output (for example, what if a widget model, not associated with a cell, sends a message?). See jupyterlab/jupyterlab#1254 for more context, and in particular the TODO items for a way to deal with the problem. The basic idea is to have a notebook-level output place for messages that don't neatly fall into a single cell. |
The question is more about where output should be displayed. In the screencast below, we show that in the case of the classic notebook, streams are redirected to the cell where the action originated. However, for other widget messages that don't originate from a specific view (e.g. with a webcam widget that would capture the webcam input), where should the message be displayed? The reasoning with jupyterlab is that this new behavior was more 'consistent', but it turned out to be less intuitive to users. |
My opinion is that all jupyter frontends should have a "debug" output area (not necessarily visible by default) that would show all output and error messages that don't have a parent header. |
Cool -- your option C, namely a debug or log page, makes good sense and solves some problems I had not anticipated. Thanks! |
And the thought was that once we have a notebook-level place for output messages in JupyterLab, it will be intuitive again. For now, we suggest that people use an output widget to capture errors: https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html#Debugging-errors-in-callbacks-with-the-output-widget |
@choldgraf, see the section in the docs about this: https://ipywidgets.readthedocs.io/en/stable/examples/Output%20Widget.html#Debugging-errors-in-callbacks-with-the-output-widget |
Closing as answered (but feel free to post here if we need to continue the discussion) |
I just tried building a simple interface using a button w/ a callback to update a bqplot. When I was using Jupyter Lab, clicking the button didn't do anything. When I switched to the classic interface, it worked fine (running Voila also worked fine). Just wanted to flag this in case it's not a known bug.
The text was updated successfully, but these errors were encountered: