metakernel icon indicating copy to clipboard operation
metakernel copied to clipboard

context manager version of outputs widget does not work with metakernel

Open joequant opened this issue 5 years ago • 0 comments

import ipywidgets
from IPython.display import display
a=1
button = ipywidgets.Button(description="Click Me!")
output = ipywidgets.Output();

def on_button_clicked(button):
    global a
    a=a+1
    with output:
       print('foo")
    output.append_stdout("bar")

button.on_click(on_button_clicked)

"foo" will not appear in the output widget but "bar"

The problem is with ipywidgets which calls get_ipython to get kernel information. This can be fixed by monkey patching widget_outputs, but for now it can be worked around by using the append_stdout syntax.

joequant avatar Aug 27 '20 17:08 joequant