The view is the one to actually send the comm message from js:
https://github.com/jupyter-widgets/ipywidgets/blob/a311d753385f0867c34525eacad9496108e43cc1/packages/controls/src/widget_button.ts#L124

In the classic Notebook, the view registers a display callback that puts
any output coming back from the kernel in the cell containing the view. The
process for getting that callback right is a bit convoluted, involving
asking the widget manager for the right callback, etc. The relevant code is
at
https://github.com/jupyter-widgets/ipywidgets/blob/a311d753385f0867c34525eacad9496108e43cc1/widgetsnbextension/src/manager.js#L311-L335

In JupyterLab, right now nothing is done with the output, so the output
essentially disappears: . We are working on a logging extension (hopefully
merged for jlab 1.2) that will log a message with any output returned from
the kernel.

In the docs, we also encourage people to use the OutputWidget to explicitly
capture output if that's what you want:
https://ipywidgets.readthedocs.io/en/latest/examples/Output%20Widget.html#Debugging-errors-in-callbacks-with-the-output-widget

Thanks,

Jason


On Mon, Sep 23, 2019 at 9:45 AM 'Ilya Kazakevich' via Project Jupyter <
[email protected]> wrote:

> Hello,
> I have the following code
>
> ```
>
> btn = widgets.Button(description='Medium')
> display(btn)
> def btn_eventhandler(obj):
>     print('Hello from the {} button!'.format(obj.description))
> btn.on_click(btn_eventhandler)
>
> ```
>
> When I click on the button, it sends comm message to python side.
> Python replies with "stream" message.
>
> As I understand, button widget uses it's model to send comm message.
> Model may have more than one view.
> So, how does jupyter know which cell should be used to output this stream?
>
> I know that for regular code execution it registers callback and uses
> "parent" header of reply, and I am sure something similar takes place here,
> but I don't see any callback registered by view nor by model.
>
> Thank you.
> Ilya.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Project Jupyter" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/CAMQsgbSoR3Smw_zHrBW%3DL4OSYgtuk1LUo71OY7bCdFAybA5JoQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/jupyter/CAMQsgbSoR3Smw_zHrBW%3DL4OSYgtuk1LUo71OY7bCdFAybA5JoQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAPDWZHwstENV7CWxVny7bKkFwqeK4gWvZcoeCX66bnkivOG_YQ%40mail.gmail.com.

Reply via email to