Jupyterlab: ipywidgets Button widget not printing text

Created on 7 Aug 2018  路  3Comments  路  Source: jupyterlab/jupyterlab

When the following code is run in JupyterLab 0.32.1 with ipywidgets 7.3.1 and @jupyter-widgets/jupyterlab-manager 0.36.1, nothing happens when the button is clicked. The word "Test" should be printed. It works in the classic Notebook.

from IPython.display import display
from ipywidgets import widgets

def test(b):
    print('Test')

button = widgets.Button(description='Test')
button.on_click(test)

display(button)
Question

Most helpful comment

Hi @scottdotjs, I believe you have to use an OutputWidget. Jupyter Notebook had a hack that allowed output to be displayed from a widget directly. cc @jasongrout, the Widget Events tutorial should be updated to use an output widget.

All 3 comments

Hi @scottdotjs, I believe you have to use an OutputWidget. Jupyter Notebook had a hack that allowed output to be displayed from a widget directly. cc @jasongrout, the Widget Events tutorial should be updated to use an output widget.

@blink1073 Perfect! Thanks very much.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aghoshpub picture aghoshpub  路  3Comments

joaonatali picture joaonatali  路  3Comments

t-makaro picture t-makaro  路  3Comments

minertom picture minertom  路  3Comments

ellisonbg picture ellisonbg  路  3Comments