I am trying to create a small project using Button and Dropdown widgets from ipywidgets in Jupyter Lab. Sample code is
btn = widgets.Button(description='Mark')
display(btn)
def btn_eventhandler(obj):
print('The name is {} !'.format(obj.description))
btn.on_click(btn_eventhandler)
I get the button but it does not give any output on clicking as seen in image below. There is no error message either.
The result that i want can be seen in the log classified under warning as seen in the image below
The same issue also arises in using Dropdown. However, Intslider widget works fine without any issues
I have tried some of the suggestions mentioned in these threads but none worked
These are the jupyter versions that are currently installed-
Is there something that I am doing wrong? I tried running the same in Jupyter Notebook where it works fine Thank you
This issue is addressed in the ipywidgets documents:
To capture prints (or any other kind of output) and ensure it is displayed, be sure to send it to an Output widget (or put the information you want to display into an HTML widget).
Here is a modified version of your sample code :