jupyterq icon indicating copy to clipboard operation
jupyterq copied to clipboard

using ipywidgets

Open amaurydar opened this issue 6 years ago • 3 comments

Most of the things I tried with ipywidgets work well, but here I don't understand what's wrong.

/%python
import ipywidgets as widgets
from IPython.display import display

out = widgets.Output()
def foo(x):
    with out:
        print(x)

b = widgets.Button(description='Button')
b.on_click(foo)

display(b)
display(out)

When calling foo('bar') directly it works well : 'bar' is printed in the Output widget. When pressing the button it doesn't.

Doing exactly the same thing with a python kernel works.

amaurydar avatar Jun 06 '18 16:06 amaurydar

Hi, Could you let me know what the expected output is here when you push the button? With the latest version of jupyterq I see the same behaviour on clicking the button as with a python 3 kernel.

JupyterQ kernel after 2 button clicks q_kernel

Python kernel after 2 button clicks. python_kernel

Do you see something different with a python kernel?

jhanna-kx avatar Jun 07 '18 13:06 jhanna-kx

The expected output is what you see. In fact I just realized that it does work in jupyter notebook, but it doesn't work in jupyter lab.

So to sum up : jupyter notebook + python kernel -> something is printed when button pressed jupyter notebook + q kernel -> something is printed when button pressed jupyter lab + python kernel -> something is printed when button pressed jupyter lab + q kernel -> nothing happens when button pressed

amaurydar avatar Jun 07 '18 20:06 amaurydar

Yes, widgets are a bit experimental and we've not done any testing with jupyterlab really as it's only in beta (moved from alpha this year I believe). Will look at adding support for widgets in jupyterlab in a future release, if you've any ideas as to what might be needed to support jupyterlab do post them here.

jhanna-kx avatar Jun 12 '18 10:06 jhanna-kx