Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-11 Thread Jason Grout
That's great to hear!

If you're at scipy right now, I'd love to touch base with you in person
about this effort.

Thanks,

Jason


On Thu, Jul 11, 2019 at 7:38 AM Ilya Kazakevich <
ilya.kazakev...@jetbrains.com> wrote:

> Jason, William, thank you.
> I now understand how this redirection works. It would be nice to document
> it somewhere in
> https://jupyter-notebook.readthedocs.io/en/stable/comms.html
>
> Yes, we are implementing ipywidgets for PyCharm:)
>
> 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 jupyter+unsubscr...@googlegroups.com.
> To post to this group, send email to jupyter@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jupyter/d5067a08-a694-4118-a653-1696c0721912%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAPDWZHwyPn%3DtFZ1SSxOn3ax%3Dh3oOB38Qqv-ZeB7Nrj2Ovn_pXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-11 Thread Ilya Kazakevich
Jason, William, thank you.
I now understand how this redirection works. It would be nice to document 
it somewhere in https://jupyter-notebook.readthedocs.io/en/stable/comms.html

Yes, we are implementing ipywidgets for PyCharm:)

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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/d5067a08-a694-4118-a653-1696c0721912%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-11 Thread Jason Grout
On Wed, Jul 10, 2019 at 8:01 PM William Stein  wrote:

> On Wed, Jul 10, 2019 at 5:51 PM Ilya Kazakevich
>  wrote:
> >
> > Thank you!
> > I was trying to understand how is it implemented technically, how it
> works under the hood
>
>
I'll also add that the answer to

> Then, how does jupyter "understands" that only widget content must be
cleared? This is not comm message, so no connection to widget is made. How
does it work?

is simple. The source for that .clear_output method is (
https://github.com/jupyter-widgets/ipywidgets/blob/b2a998402120c2b9a277508efd7453f678c5785e/ipywidgets/widgets/widget_output.py#L76-L77
):

with self:
clear_output(*pargs, **kwargs)

which means that calling that method *first* sends a comm message
redirecting output, *then* sends the global clear_output message (which is
redirected to the widget), then exits the context manager undoing the
output redirection.



> If that GitHub issue I pointed to isn't sufficiently clear, please
> reopen it and add additional questions or make a new one.  Jason Grout
> told me that he really likes using GitHub issues to answer technical
> questions about how ipywidgets works.
>
>
I like using GitHub issues because they seem to better support answers (for
example, I can inline code and links and they are formatted nicely), and
they are more searchable than chat or I think even mailing list posts. So
our "reference" issue milestone has accumulated a number of stack overflow
type questions and answers.



> Are you guys implementing IPywidgets support for PyCharm?   Having
> recently implemented a new client (not jupyterlab or jupyter classic),
> I think it will be very good for the ipywidgets project if there are
> even more integrations of ipywidgets into different clients out there...
>
>
+1 to having more clients implement ipywidgets support. Are you? Let us
know if you are having any other issues. Output widgets in particular are
still a bit tricky.

Thanks (and thanks William for answering as well!)

Jason

-- 
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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CAPDWZHxQh_0SRGTwgU1HW5YoRPm9OUP92JR%2Bg24TF_Rn8zEvpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-10 Thread William Stein
On Wed, Jul 10, 2019 at 5:51 PM Ilya Kazakevich
 wrote:
>
> Thank you!
> I was trying to understand how is it implemented technically, how it works 
> under the hood

If that GitHub issue I pointed to isn't sufficiently clear, please
reopen it and add additional questions or make a new one.  Jason Grout
told me that he really likes using GitHub issues to answer technical
questions about how ipywidgets works.

Are you guys implementing IPywidgets support for PyCharm?   Having
recently implemented a new client (not jupyterlab or jupyter classic),
I think it will be very good for the ipywidgets project if there are
even more integrations of ipywidgets into different clients out there...


 -- William

-- 
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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CACLE5GDtAe0orON1q3y_WMJRq%3D10yVVtxMzAd4rEnfhfa9VZGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-10 Thread Ilya Kazakevich
Thank you!
I was trying to understand how is it implemented technically, how it works 
under the hood

-- 
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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/a5eb471d-8c74-48fe-bdab-aa75bc100d77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [jupyter] clear_output and display widgets (from ipywidgets) connection

2019-07-10 Thread William Stein
On Wed, Jul 10, 2019 at 5:00 PM Ilya Kazakevich
 wrote:
>
> Hello,
>
> According to manual, ``clear_output`` event should clear whole cell output.
>
> But with the following code
>
> from ipywidgets import widgets
> from IPython.display import clear_output
> out = widgets.Output(layout={'border': '1px solid black'})
> out.append_display_data(10)
> display(out)
> display("20")
> out.clear_output()
>
> only "10" is cleared, while "20" stays untouched.

The above behavior is correct, and what I would expect.  The reason is
because `out.clear_output()` **only** clears the output of the widget
"out".  The "20" that you've output has nothing to do with that output
widget (the one called "out").  The "20" is simply a completely
separate output.To clear everything, which is I think the behavior
you expect, do this, which should work as you want:

from ipywidgets import widgets
from IPython.display import clear_output
out = widgets.Output(layout={'border': '1px solid black'})
out.append_display_data(10)
display(out)
display("20")
clear_output() # NOTICE: I'm calling the global clear_output
function, not the clear_output method of out.

-- William

>
> I sniffed websocket, and I see absolutely regular "clear_output" is sent.
> Then, how does jupyter "understands" that only widget content must be 
> cleared? This is not comm message, so no connection to widget is made.
> How does it work?

It's because you type "out.clear_output()" instead of
"clear_output()".   This causes a comm message to get sent from the
kernel to the widget saying "clear me".   The way out.clear_output
works is a bit surprising, since it involves different back and forth
communication between the kernel and the frontend than you might
expect.  This confused me a lot when I was implementing widgets for
CoCalc recently.  Search for "clear_output" on this page
https://github.com/jupyter-widgets/ipywidgets/issues/2385#issuecomment-484742927
for where Jason Grout clears up my confusion about how this work...

 -- William

>
> Any help (doc or source link probably) is appreciated.
>
> 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 jupyter+unsubscr...@googlegroups.com.
> To post to this group, send email to jupyter@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jupyter/11d9b97c-5827-4b48-b424-63c92c8f6de5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
William (http://wstein.org)

-- 
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 jupyter+unsubscr...@googlegroups.com.
To post to this group, send email to jupyter@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jupyter/CACLE5GAGZNpa6MYZW6d46dohGtpbG0nVg5vyPPwSBKy0MNv-SA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.