jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.13k stars 949 forks source link

Ability to disable specific dropdown elements #1728

Open pbugnion opened 6 years ago

pbugnion commented 6 years ago

When I create a select in HTML, I can disable certain attributes:

<html>
  <head></head>
  <body>
    <select>
      <option value="volvo">Volvo</option>
      <option value="mercedes">Mercedes</option>
      <option value="audi" disabled>Audi</option>
    </select>
  </body>
</html>

At the moment, as far as I can tell, that's not possible with the Dropdown widget. Is this something that would be worth including?

If so, happy to take a look at this, unless someone else gets there first.

jasongrout commented 6 years ago

The model used in a dropdown is the SelectionModel, used for other things as well. If we support disabled items in the dropdown, it probably makes sense to support them in the other widgets based on the SelectionModel as well.

basnijholt commented 4 years ago

This would be useful to add separators in a dropdown list like: image

Taken from this StackOverflow answer.