I'm trying to write a simple user interface for Python code in a Jupyter/IPython notebook. I'm using the amazing ipywidgets. I need to find a way to prevent users from clearing the widgets by accidentally clicking the <button class="close">×</button>
(the X
to the left of the widgets). I've spent hours searching for a simple way to do this. Here's a simple, minimal example of the issue in a single Jupyter notebook cell:
import ipywidgets
import IPython.display
w = ipywidgets.IntSlider()
IPython.display.display(w)
The result is a slider with the widget clear button X
to the left of the slider:
Image of slider with widget clear button X
How can I remove or disable the widget clear button so that the user can't accidentally clear the widget?