I built a cascade of two combobox widgets, in which the value of the first updates the options on the second. Selecting the value of the first combobox initially correctly updates the second combobox, but at every change of value in the first one, the shown options of the second are not reset and just add up. The options attribute of the object itself seems to correctly contain just the updated values, and indeed selecting an "old" value from the second combobox seems to lead to some invalid actions (i.e. the value is not recognised with ensure_option=True).
Reproduce
here some minimal code to reproduce the issue:
wdgt_list = []
cb_1 = wdgt.Combobox(options=[str(eee) for eee in range(10)], description="cb1")
wdgt_list.append(cb_1)
cb_2 = wdgt.Combobox(options=[], description="cb2")
wdgt_list.append(cb_2)
def on_1(_):
cb_2.options = [f"{cb_1.value}+{eee}" for eee in range(10)]
cb_2.value = ""
cb_1.observe(on_1, names="value")
wdgt.VBox(wdgt_list)
in order to reproduce the issue, just select values from the first combobox.
Expected behavior
the second combobox should show just the updated options, according to the selected value in the first combobox. If Dropdown is used instead, the code seems to work properly.
Context
ipywidgets version 8.0.4
Operating System and version: Ubuntu 22.04.1 LTS (from docker image jupyter/scipy-notebook:python-3.10.8)
Browser and version: Google Chrome 109.0.5414.119 (x86_64)
prod-main-container-1 | [W 2023-01-27 20:37:37.082 ServerApp] ServerApp.token config is deprecated in 2.0. Use IdentityProvider.token.
prod-main-container-1 | [I 2023-01-27 20:37:37.143 ServerApp] jupyter_server_terminals | extension was successfully linked.
prod-main-container-1 | [I 2023-01-27 20:37:37.161 ServerApp] jupyterlab | extension was successfully linked.
prod-main-container-1 | [W 2023-01-27 20:37:37.171 NotebookApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
prod-main-container-1 | [W 2023-01-27 20:37:37.171 NotebookApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
prod-main-container-1 | [I 2023-01-27 20:37:37.178 ServerApp] nbclassic | extension was successfully linked.
prod-main-container-1 | [I 2023-01-27 20:37:37.182 ServerApp] Writing Jupyter server cookie secret to /tmp/jupyter_cookie_secret
prod-main-container-1 | [I 2023-01-27 20:37:37.471 ServerApp] notebook_shim | extension was successfully linked.
prod-main-container-1 | [I 2023-01-27 20:37:37.703 ServerApp] notebook_shim | extension was successfully loaded.
prod-main-container-1 | [I 2023-01-27 20:37:37.704 ServerApp] jupyter_server_terminals | extension was successfully loaded.
prod-main-container-1 | [I 2023-01-27 20:37:37.705 LabApp] JupyterLab extension loaded from /opt/conda/lib/python3.10/site-packages/jupyterlab
prod-main-container-1 | [I 2023-01-27 20:37:37.705 LabApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
prod-main-container-1 | [I 2023-01-27 20:37:37.708 ServerApp] jupyterlab | extension was successfully loaded.
prod-main-container-1 | [I 2023-01-27 20:37:37.712 ServerApp] nbclassic | extension was successfully loaded.
prod-main-container-1 | [I 2023-01-27 20:37:37.713 ServerApp] Serving notebooks from local directory: /home/jovyan
prod-main-container-1 | [I 2023-01-27 20:37:37.713 ServerApp] Jupyter Server 2.1.0 is running at:
prod-main-container-1 | [I 2023-01-27 20:37:37.713 ServerApp] or http://127.0.0.1:8888/lab?token=...
prod-main-container-1 | [I 2023-01-27 20:37:37.713 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
prod-main-container-1 | [I 2023-01-27 20:37:41.216 LabApp] Build is up to date
Description
I built a cascade of two combobox widgets, in which the value of the first updates the options on the second. Selecting the value of the first combobox initially correctly updates the second combobox, but at every change of value in the first one, the shown options of the second are not reset and just add up. The options attribute of the object itself seems to correctly contain just the updated values, and indeed selecting an "old" value from the second combobox seems to lead to some invalid actions (i.e. the value is not recognised with
ensure_option=True
).Reproduce
here some minimal code to reproduce the issue:
in order to reproduce the issue, just select values from the first combobox.
Expected behavior
the second combobox should show just the updated options, according to the selected value in the first combobox. If Dropdown is used instead, the code seems to work properly.
Context
Troubleshoot Output
Command Line Output
If using JupyterLab
Installed Labextensions