context manager version of outputs widget does not work with metakernel
joequant opened this issue · 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.