jupyter-widgets / ipywidgets

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

Resetting options for `SelectionSlider` doesn't seem to work properly #3885

Open amine-aboufirass opened 4 months ago

amine-aboufirass commented 4 months ago

Description

Resetting options for a SelectionSlider in an update handler won't properly update its value. This seems to occur only when the length of the new option list differs from the length of the old option list.

Reproduce

import ipywidgets as widgets

data = {
    "A": [1,4,5,7],
    "B": [123, 452, 546],
    "C": [-23, 23,34, 342, ]
}

slider = widgets.SelectionSlider(options=data["A"], description='Slider')
dropdown = widgets.Dropdown(options=["A", "B", "C"], description="Value")

def update(change):
    slider.options = data[dropdown.value]

dropdown.observe(update, "value")

display(slider, dropdown)

enter image description here

enter image description here

Expected behavior

I expected the slider to jump back to the first value of the option set for b which is 123. In other words, all the way to the right.

Context

Troubleshoot Output
$PATH:
    C:\Users\aa\Miniconda3
    C:\Users\aa\Miniconda3\Library\mingw-w64\bin
    C:\Users\aa\Miniconda3\Library\usr\bin
    C:\Users\aa\Miniconda3\Library\bin
    C:\Users\aa\Miniconda3\Scripts
    C:\Users\aa\Miniconda3\bin
    C:\Users\aa\Miniconda3\condabin
    C:\Program Files\PowerShell\7
    C:\texlive\2023\bin\windows
    C:\Program Files\Eclipse Adoptium\jdk-18.0.2.9-hotspot\bin
    C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin
    C:\Python310\Scripts
    C:\Python310
    C:\Program Files\Eclipse Adoptium\jre-18.0.2.9-hotspot\bin
    C:\windows\system32
    C:\windows
    C:\windows\System32\Wbem
    C:\windows\System32\WindowsPowerShell\v1.0
    C:\windows\System32\OpenSSH
    C:\Program Files\dotnet
    C:\Program Files\Microsoft SQL Server\130\Tools\Binn
    C:\ProgramData\chocolatey\bin
    C:\Program Files\Git\cmd
    C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn
    C:\Program Files\Microsoft SQL Server\140\Tools\Binn
    C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
    C:\Program Files\Microsoft SQL Server\140\DTS\Binn
    C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn
    C:\Program Files\Azure Data Studio\bin
    C:\Program Files\1E\Client\Extensibility\NomadBranch
    C:\Program Files\WindowsPowerShell\Scripts\HP.ClientScriptLibrary
    C:\Program Files\GitHub CLI
    C:\Program Files\PowerShell\7
    C:\Program Files\nodejs
    C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin
    C:\Program Files\Microsoft SQL Server\150\Tools\Binn
    C:\Program Files\TortoiseGit\bin
    C:\Program Files\LLVM\bin
    .
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0
    C:\WINDOWS\System32\OpenSSH
    C:\Users\aa\AppData\Local\Microsoft\WindowsApps
    C:\Users\aa\.dotnet\tools
    C:\Program Files\SumatraPDF
    C:\Users\aa\AppData\Local\Programs\oh-my-posh\bin
    C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin
    C:\Program Files\Azure Data Studio\bin
    C:\Users\aa\OneDrive - Shell\Documents\PowerShell\Scripts
    C:\Program Files\WinMerge
    C:\Users\aa\Desktop\TEMP\Handle
    C:\Program Files\JetBrains\PyCharm Community Edition 2022.2\bin
    C:\Users\aa\AppData\Roaming\npm
    C:\Users\aa\AppData\Local\Google\Chrome\Application
    C:\Program Files\Inkscape\bin
    C:\Users\aa\Desktop\SETUPS\mf6.4.1\bin
    C:\Users\aa\Desktop\SETUPS\osmosis-0.48.3\bin
    C:\Users\aa\.dotnet\tools
    C:\Users\aa\AppData\Local\Pandoc
    C:\Users\aa\Desktop\SETUPS\pandoc-filters
    C:\Program Files\Notepad++
    C:\Users\aa\AppData\Roaming\Python\Python310\Scripts
    C:\Users\aa\AppData\Local\Programs\Microsoft VS Code\bin
    C:\tools\neovim\nvim-win64\bin
    C:\Users\aa\AppData\Local\Programs\ILSpy
    C:\dita-ot-2.5.4\bin
    C:\Program Files\wkhtmltopdf\bin
    C:\Users\aa\Desktop\SETUPS\netcoredbg-win64\netcoredbg
    C:\Users\aa\AppData\Local\Microsoft\WindowsApps
    C:\Users\aa\Desktop\SETUPS\sqlite-tools-win-x64-3450100
    .

sys.path:
    C:\Users\aa\Miniconda3\Scripts
    C:\Users\aa\Miniconda3\python39.zip
    C:\Users\aa\Miniconda3\DLLs
    C:\Users\aa\Miniconda3\lib
    C:\Users\aa\Miniconda3
    C:\Users\aa\Miniconda3\lib\site-packages
    C:\Users\aa\Miniconda3\lib\site-packages\win32
    C:\Users\aa\Miniconda3\lib\site-packages\win32\lib
    C:\Users\aa\Miniconda3\lib\site-packages\Pythonwin

sys.executable:
    C:\Users\aa\Miniconda3\python.exe

sys.version:
    3.9.18 (main, Sep 11 2023, 14:09:26) [MSC v.1916 64 bit (AMD64)]

platform.platform():
    Windows-10-10.0.22621-SP0

where jupyter:
    C:\Users\aa\Miniconda3\Scripts\jupyter.exe

pip list:
    Package                   Version

    ------------------------- ------------

    aiofiles                  22.1.0

    aiosqlite                 0.18.0

    anyio                     3.5.0

    argon2-cffi               21.3.0

    argon2-cffi-bindings      21.2.0

    asttokens                 2.0.5

    attrs                     23.1.0

    Babel                     2.11.0

    backcall                  0.2.0

    beautifulsoup4            4.12.2

    bleach                    4.1.0

    Brotli                    1.0.9

    certifi                   2024.2.2

    cffi                      1.16.0

    charset-normalizer        2.0.4

    colorama                  0.4.6

    comm                      0.1.2

    conda                     4.14.0

    conda-package-handling    2.2.0

    conda_package_streaming   0.9.0

    cryptography              41.0.7

    cycler                    0.12.1

    debugpy                   1.6.7

    decorator                 5.1.1

    defusedxml                0.7.1

    entrypoints               0.4

    exceptiongroup            1.2.0

    executing                 0.8.3

    fastjsonschema            2.16.2

    idna                      3.4

    importlib-metadata        7.0.1

    ipykernel                 6.25.0

    ipympl                    0.9.3

    ipython                   8.15.0

    ipython-genutils          0.2.0

    ipywidgets                8.0.3

    jedi                      0.18.1

    Jinja2                    3.1.3

    json5                     0.9.6

    jsonschema                4.19.2

    jsonschema-specifications 2023.7.1

    jupyter_client            7.4.9

    jupyter_core              5.5.0

    jupyter-events            0.8.0

    jupyter-server            1.23.4

    jupyter_server_fileid     0.9.0

    jupyter_server_ydoc       0.8.0

    jupyter-ydoc              0.2.4

    jupyterlab                3.6.3

    jupyterlab-pygments       0.2.2

    jupyterlab_server         2.25.1

    jupyterlab_widgets        3.0.10

    kiwisolver                1.4.4

    MarkupSafe                2.1.3

    matplotlib                3.4.3

    matplotlib-inline         0.1.6

    menuinst                  1.4.19

    mistune                   2.0.4

    nb-conda-kernels          2.3.1

    nbclassic                 1.0.0

    nbclient                  0.8.0

    nbconvert                 7.10.0

    nbformat                  5.9.2

    nest-asyncio              1.5.6

    notebook                  6.5.4

    notebook_shim             0.2.3

    numpy                     1.22.4

    packaging                 23.1

    pandocfilters             1.5.0

    parso                     0.8.3

    pickleshare               0.7.5

    pillow                    10.2.0

    pip                       23.3.1

    platformdirs              3.10.0

    prometheus-client         0.14.1

    prompt-toolkit            3.0.43

    psutil                    5.9.0

    pure-eval                 0.2.2

    pycosat                   0.6.6

    pycparser                 2.21

    Pygments                  2.15.1

    pyOpenSSL                 23.2.0

    pyparsing                 3.1.1

    PySocks                   1.7.1

    python-dateutil           2.8.2

    python-json-logger        2.0.7

    pytz                      2023.3.post1

    pywin32                   305.1

    pywinpty                  2.0.10

    PyYAML                    6.0.1

    pyzmq                     23.2.0

    referencing               0.30.2

    requests                  2.31.0

    rfc3339-validator         0.1.4

    rfc3986-validator         0.1.1

    rpds-py                   0.10.6

    ruamel-yaml-conda         0.15.100

    Send2Trash                1.8.2

    setuptools                68.2.2

    six                       1.16.0

    sniffio                   1.3.0

    soupsieve                 2.5

    stack-data                0.2.0

    terminado                 0.17.1

    tinycss2                  1.2.1

    tomli                     2.0.1

    toolz                     0.12.0

    tornado                   6.3.3

    traitlets                 5.7.1

    typing_extensions         4.9.0

    urllib3                   2.1.0

    wcwidth                   0.2.5

    webencodings              0.5.1

    websocket-client          0.58.0

    wheel                     0.41.2

    widgetsnbextension        4.0.10

    win-inet-pton             1.1.0

    y-py                      0.5.9

    ypy-websocket             0.8.2

    zipp                      3.17.0

    zstandard                 0.19.0

conda list:
    # packages in environment at C:\Users\aa\Miniconda3:

    #

    # Name                    Version                   Build  Channel

    aiofiles                  22.1.0           py39haa95532_0  

    aiosqlite                 0.18.0           py39haa95532_0  

    anyio                     3.5.0            py39haa95532_0  

    argon2-cffi               21.3.0             pyhd3eb1b0_0  

    argon2-cffi-bindings      21.2.0           py39h2bbff1b_0  

    asttokens                 2.0.5              pyhd3eb1b0_0  

    attrs                     23.1.0           py39haa95532_0  

    babel                     2.11.0           py39haa95532_0  

    backcall                  0.2.0              pyhd3eb1b0_0  

    beautifulsoup4            4.12.2           py39haa95532_0  

    bleach                    4.1.0              pyhd3eb1b0_0  

    brotli-python             1.0.9            py39hd77b12b_7  

    ca-certificates           2024.2.2             h56e8100_0    conda-forge

    certifi                   2024.2.2           pyhd8ed1ab_0    conda-forge

    cffi                      1.16.0           py39h2bbff1b_0  

    charset-normalizer        2.0.4              pyhd3eb1b0_0  

    colorama                  0.4.6            py39haa95532_0  

    comm                      0.1.2            py39haa95532_0  

    conda                     4.14.0           py39hcbf5309_0    conda-forge

    conda-package-handling    2.2.0            py39haa95532_0  

    conda-package-streaming   0.9.0            py39haa95532_0  

    console_shortcut          0.1.1                         4  

    cryptography              41.0.7           py39h89fc84f_0  

    cycler                    0.12.1             pyhd8ed1ab_0    conda-forge

    debugpy                   1.6.7            py39hd77b12b_0  

    decorator                 5.1.1              pyhd3eb1b0_0  

    defusedxml                0.7.1              pyhd3eb1b0_0  

    entrypoints               0.4              py39haa95532_0  

    exceptiongroup            1.2.0            py39haa95532_0  

    executing                 0.8.3              pyhd3eb1b0_0  

    freetype                  2.10.4               h546665d_1    conda-forge

    idna                      3.4              py39haa95532_0  

    importlib-metadata        7.0.1            py39haa95532_0  

    importlib_metadata        7.0.1                hd3eb1b0_0  

    intel-openmp              2024.0.0         h57928b3_49841    conda-forge

    ipykernel                 6.25.0           py39h9909e9c_0  

    ipympl                    0.9.3              pyhd8ed1ab_0    conda-forge

    ipython                   8.15.0           py39haa95532_0  

    ipython_genutils          0.2.0              pyhd3eb1b0_1  

    ipywidgets                8.0.3              pyhd8ed1ab_0    conda-forge

    jedi                      0.18.1           py39haa95532_1  

    jinja2                    3.1.3            py39haa95532_0  

    jpeg                      9e                   h8ffe710_2    conda-forge

    json5                     0.9.6              pyhd3eb1b0_0  

    jsonschema                4.19.2           py39haa95532_0  

    jsonschema-specifications 2023.7.1         py39haa95532_0  

    jupyter_client            7.4.9            py39haa95532_0  

    jupyter_core              5.5.0            py39haa95532_0  

    jupyter_events            0.8.0            py39haa95532_0  

    jupyter_server            1.23.4           py39haa95532_0  

    jupyter_server_fileid     0.9.0            py39haa95532_0  

    jupyter_server_ydoc       0.8.0            py39haa95532_1  

    jupyter_ydoc              0.2.4            py39haa95532_0  

    jupyterlab                3.6.3            py39haa95532_0  

    jupyterlab_pygments       0.2.2            py39haa95532_0  

    jupyterlab_server         2.25.1           py39haa95532_0  

    jupyterlab_widgets        3.0.10             pyhd8ed1ab_0    conda-forge

    kiwisolver                1.4.4            py39hd77b12b_0  

    lerc                      3.0                  hd77b12b_0  

    libblas                   3.9.0                     8_mkl    conda-forge

    libcblas                  3.9.0                     8_mkl    conda-forge

    libdeflate                1.17                 h2bbff1b_1  

    liblapack                 3.9.0                     8_mkl    conda-forge

    libpng                    1.6.39               h8cc25b3_0  

    libsodium                 1.0.18               h62dcd97_0  

    libtiff                   4.5.1                hd77b12b_0  

    libwebp-base              1.3.2                h2bbff1b_0  

    lz4-c                     1.9.4                h2bbff1b_0  

    markupsafe                2.1.3            py39h2bbff1b_0  

    matplotlib-base           3.4.3            py39h581301d_2    conda-forge

    matplotlib-inline         0.1.6            py39haa95532_0  

    menuinst                  1.4.19           py39h59b6b97_0  

    mistune                   2.0.4            py39haa95532_0  

    mkl                       2020.4             hb70f87d_311    conda-forge

    nb_conda_kernels          2.3.1            py39haa95532_0  

    nbclassic                 1.0.0            py39haa95532_0  

    nbclient                  0.8.0            py39haa95532_0  

    nbconvert                 7.10.0           py39haa95532_0  

    nbformat                  5.9.2            py39haa95532_0  

    nest-asyncio              1.5.6            py39haa95532_0  

    notebook                  6.5.4            py39haa95532_1  

    notebook-shim             0.2.3            py39haa95532_0  

    numpy                     1.22.4           py39h0948cea_0    conda-forge

    openjpeg                  2.4.0                h4fc8c34_0  

    openssl                   3.0.13               h2bbff1b_0  

    packaging                 23.1             py39haa95532_0  

    pandocfilters             1.5.0              pyhd3eb1b0_0  

    parso                     0.8.3              pyhd3eb1b0_0  

    pickleshare               0.7.5           pyhd3eb1b0_1003  

    pillow                    10.2.0           py39h2bbff1b_0  

    pip                       23.3.1           py39haa95532_0  

    platformdirs              3.10.0           py39haa95532_0  

    powershell_shortcut       0.0.1                         3  

    prometheus_client         0.14.1           py39haa95532_0  

    prompt-toolkit            3.0.43           py39haa95532_0  

    psutil                    5.9.0            py39h2bbff1b_0  

    pure_eval                 0.2.2              pyhd3eb1b0_0  

    pycosat                   0.6.6            py39h2bbff1b_0  

    pycparser                 2.21               pyhd3eb1b0_0  

    pygments                  2.15.1           py39haa95532_1  

    pyopenssl                 23.2.0           py39haa95532_0  

    pyparsing                 3.1.1              pyhd8ed1ab_0    conda-forge

    pysocks                   1.7.1            py39haa95532_0  

    python                    3.9.18               h1aa4202_0  

    python-dateutil           2.8.2              pyhd3eb1b0_0  

    python-fastjsonschema     2.16.2           py39haa95532_0  

    python-json-logger        2.0.7            py39haa95532_0  

    python_abi                3.9                      2_cp39    conda-forge

    pytz                      2023.3.post1     py39haa95532_0  

    pywin32                   305              py39h2bbff1b_0  

    pywinpty                  2.0.10           py39h5da7b33_0  

    pyyaml                    6.0.1            py39h2bbff1b_0  

    pyzmq                     23.2.0           py39hd77b12b_0  

    referencing               0.30.2           py39haa95532_0  

    requests                  2.31.0           py39haa95532_1  

    rfc3339-validator         0.1.4            py39haa95532_0  

    rfc3986-validator         0.1.1            py39haa95532_0  

    rpds-py                   0.10.6           py39h062c2fa_0  

    ruamel_yaml               0.15.100         py39h2bbff1b_0  

    send2trash                1.8.2            py39haa95532_0  

    setuptools                68.2.2           py39haa95532_0  

    six                       1.16.0             pyhd3eb1b0_1  

    sniffio                   1.3.0            py39haa95532_0  

    soupsieve                 2.5              py39haa95532_0  

    sqlite                    3.41.2               h2bbff1b_0  

    stack_data                0.2.0              pyhd3eb1b0_0  

    terminado                 0.17.1           py39haa95532_0  

    tinycss2                  1.2.1            py39haa95532_0  

    tomli                     2.0.1            py39haa95532_0  

    toolz                     0.12.0           py39haa95532_0  

    tornado                   6.3.3            py39h2bbff1b_0  

    traitlets                 5.7.1            py39haa95532_0  

    typing-extensions         4.9.0            py39haa95532_1  

    typing_extensions         4.9.0            py39haa95532_1  

    tzdata                    2023d                h04d1e81_0  

    urllib3                   2.1.0            py39haa95532_1  

    vc                        14.2                 h21ff451_1  

    vs2015_runtime            14.27.29016          h5e58377_2  

    wcwidth                   0.2.5              pyhd3eb1b0_0  

    webencodings              0.5.1            py39haa95532_1  

    websocket-client          0.58.0           py39haa95532_4  

    wheel                     0.41.2           py39haa95532_0  

    widgetsnbextension        4.0.10             pyhd8ed1ab_0    conda-forge

    win_inet_pton             1.1.0            py39haa95532_0  

    winpty                    0.4.3                         4  

    xz                        5.4.5                h8cc25b3_0  

    y-py                      0.5.9            py39hb6bf4ef_0  

    yaml                      0.2.5                he774522_0  

    ypy-websocket             0.8.2            py39haa95532_0  

    zeromq                    4.3.4                hd77b12b_0  

    zipp                      3.17.0           py39haa95532_0  

    zlib                      1.2.13               h8cc25b3_0  

    zstandard                 0.19.0           py39h2bbff1b_0  

    zstd                      1.5.5                hd43e919_0

conda env:
    name: base

    channels:

      - conda-forge

      - defaults

    dependencies:

      - aiofiles=22.1.0=py39haa95532_0

      - aiosqlite=0.18.0=py39haa95532_0

      - anyio=3.5.0=py39haa95532_0

      - argon2-cffi=21.3.0=pyhd3eb1b0_0

      - argon2-cffi-bindings=21.2.0=py39h2bbff1b_0

      - asttokens=2.0.5=pyhd3eb1b0_0

      - attrs=23.1.0=py39haa95532_0

      - babel=2.11.0=py39haa95532_0

      - backcall=0.2.0=pyhd3eb1b0_0

      - beautifulsoup4=4.12.2=py39haa95532_0

      - bleach=4.1.0=pyhd3eb1b0_0

      - brotli-python=1.0.9=py39hd77b12b_7

      - ca-certificates=2024.2.2=h56e8100_0

      - certifi=2024.2.2=pyhd8ed1ab_0

      - cffi=1.16.0=py39h2bbff1b_0

      - charset-normalizer=2.0.4=pyhd3eb1b0_0

      - colorama=0.4.6=py39haa95532_0

      - comm=0.1.2=py39haa95532_0

      - conda=4.14.0=py39hcbf5309_0

      - conda-package-handling=2.2.0=py39haa95532_0

      - conda-package-streaming=0.9.0=py39haa95532_0

      - console_shortcut=0.1.1=4

      - cryptography=41.0.7=py39h89fc84f_0

      - cycler=0.12.1=pyhd8ed1ab_0

      - debugpy=1.6.7=py39hd77b12b_0

      - decorator=5.1.1=pyhd3eb1b0_0

      - defusedxml=0.7.1=pyhd3eb1b0_0

      - entrypoints=0.4=py39haa95532_0

      - exceptiongroup=1.2.0=py39haa95532_0

      - executing=0.8.3=pyhd3eb1b0_0

      - freetype=2.10.4=h546665d_1

      - idna=3.4=py39haa95532_0

      - importlib-metadata=7.0.1=py39haa95532_0

      - importlib_metadata=7.0.1=hd3eb1b0_0

      - intel-openmp=2024.0.0=h57928b3_49841

      - ipykernel=6.25.0=py39h9909e9c_0

      - ipympl=0.9.3=pyhd8ed1ab_0

      - ipython=8.15.0=py39haa95532_0

      - ipython_genutils=0.2.0=pyhd3eb1b0_1

      - ipywidgets=8.0.3=pyhd8ed1ab_0

      - jedi=0.18.1=py39haa95532_1

      - jinja2=3.1.3=py39haa95532_0

      - jpeg=9e=h8ffe710_2

      - json5=0.9.6=pyhd3eb1b0_0

      - jsonschema=4.19.2=py39haa95532_0

      - jsonschema-specifications=2023.7.1=py39haa95532_0

      - jupyter_client=7.4.9=py39haa95532_0

      - jupyter_core=5.5.0=py39haa95532_0

      - jupyter_events=0.8.0=py39haa95532_0

      - jupyter_server=1.23.4=py39haa95532_0

      - jupyter_server_fileid=0.9.0=py39haa95532_0

      - jupyter_server_ydoc=0.8.0=py39haa95532_1

      - jupyter_ydoc=0.2.4=py39haa95532_0

      - jupyterlab=3.6.3=py39haa95532_0

      - jupyterlab_pygments=0.2.2=py39haa95532_0

      - jupyterlab_server=2.25.1=py39haa95532_0

      - jupyterlab_widgets=3.0.10=pyhd8ed1ab_0

      - kiwisolver=1.4.4=py39hd77b12b_0

      - lerc=3.0=hd77b12b_0

      - libblas=3.9.0=8_mkl

      - libcblas=3.9.0=8_mkl

      - libdeflate=1.17=h2bbff1b_1

      - liblapack=3.9.0=8_mkl

      - libpng=1.6.39=h8cc25b3_0

      - libsodium=1.0.18=h62dcd97_0

      - libtiff=4.5.1=hd77b12b_0

      - libwebp-base=1.3.2=h2bbff1b_0

      - lz4-c=1.9.4=h2bbff1b_0

      - markupsafe=2.1.3=py39h2bbff1b_0

      - matplotlib-base=3.4.3=py39h581301d_2

      - matplotlib-inline=0.1.6=py39haa95532_0

      - menuinst=1.4.19=py39h59b6b97_0

      - mistune=2.0.4=py39haa95532_0

      - mkl=2020.4=hb70f87d_311

      - nb_conda_kernels=2.3.1=py39haa95532_0

      - nbclassic=1.0.0=py39haa95532_0

      - nbclient=0.8.0=py39haa95532_0

      - nbconvert=7.10.0=py39haa95532_0

      - nbformat=5.9.2=py39haa95532_0

      - nest-asyncio=1.5.6=py39haa95532_0

      - notebook=6.5.4=py39haa95532_1

      - notebook-shim=0.2.3=py39haa95532_0

      - numpy=1.22.4=py39h0948cea_0

      - openjpeg=2.4.0=h4fc8c34_0

      - openssl=3.0.13=h2bbff1b_0

      - packaging=23.1=py39haa95532_0

      - pandocfilters=1.5.0=pyhd3eb1b0_0

      - parso=0.8.3=pyhd3eb1b0_0

      - pickleshare=0.7.5=pyhd3eb1b0_1003

      - pillow=10.2.0=py39h2bbff1b_0

      - pip=23.3.1=py39haa95532_0

      - platformdirs=3.10.0=py39haa95532_0

      - powershell_shortcut=0.0.1=3

      - prometheus_client=0.14.1=py39haa95532_0

      - prompt-toolkit=3.0.43=py39haa95532_0

      - psutil=5.9.0=py39h2bbff1b_0

      - pure_eval=0.2.2=pyhd3eb1b0_0

      - pycosat=0.6.6=py39h2bbff1b_0

      - pycparser=2.21=pyhd3eb1b0_0

      - pygments=2.15.1=py39haa95532_1

      - pyopenssl=23.2.0=py39haa95532_0

      - pyparsing=3.1.1=pyhd8ed1ab_0

      - pysocks=1.7.1=py39haa95532_0

      - python=3.9.18=h1aa4202_0

      - python-dateutil=2.8.2=pyhd3eb1b0_0

      - python-fastjsonschema=2.16.2=py39haa95532_0

      - python-json-logger=2.0.7=py39haa95532_0

      - python_abi=3.9=2_cp39

      - pytz=2023.3.post1=py39haa95532_0

      - pywin32=305=py39h2bbff1b_0

      - pywinpty=2.0.10=py39h5da7b33_0

      - pyyaml=6.0.1=py39h2bbff1b_0

      - pyzmq=23.2.0=py39hd77b12b_0

      - referencing=0.30.2=py39haa95532_0

      - requests=2.31.0=py39haa95532_1

      - rfc3339-validator=0.1.4=py39haa95532_0

      - rfc3986-validator=0.1.1=py39haa95532_0

      - rpds-py=0.10.6=py39h062c2fa_0

      - ruamel_yaml=0.15.100=py39h2bbff1b_0

      - send2trash=1.8.2=py39haa95532_0

      - setuptools=68.2.2=py39haa95532_0

      - six=1.16.0=pyhd3eb1b0_1

      - sniffio=1.3.0=py39haa95532_0

      - soupsieve=2.5=py39haa95532_0

      - sqlite=3.41.2=h2bbff1b_0

      - stack_data=0.2.0=pyhd3eb1b0_0

      - terminado=0.17.1=py39haa95532_0

      - tinycss2=1.2.1=py39haa95532_0

      - tomli=2.0.1=py39haa95532_0

      - toolz=0.12.0=py39haa95532_0

      - tornado=6.3.3=py39h2bbff1b_0

      - traitlets=5.7.1=py39haa95532_0

      - typing-extensions=4.9.0=py39haa95532_1

      - typing_extensions=4.9.0=py39haa95532_1

      - tzdata=2023d=h04d1e81_0

      - urllib3=2.1.0=py39haa95532_1

      - vc=14.2=h21ff451_1

      - vs2015_runtime=14.27.29016=h5e58377_2

      - wcwidth=0.2.5=pyhd3eb1b0_0

      - webencodings=0.5.1=py39haa95532_1

      - websocket-client=0.58.0=py39haa95532_4

      - wheel=0.41.2=py39haa95532_0

      - widgetsnbextension=4.0.10=pyhd8ed1ab_0

      - win_inet_pton=1.1.0=py39haa95532_0

      - winpty=0.4.3=4

      - xz=5.4.5=h8cc25b3_0

      - y-py=0.5.9=py39hb6bf4ef_0

      - yaml=0.2.5=he774522_0

      - ypy-websocket=0.8.2=py39haa95532_0

      - zeromq=4.3.4=hd77b12b_0

      - zipp=3.17.0=py39haa95532_0

      - zlib=1.2.13=h8cc25b3_0

      - zstandard=0.19.0=py39h2bbff1b_0

      - zstd=1.5.5=hd43e919_0

    prefix: C:\Users\aa\Miniconda3
Command Line Output
Paste the output from your command line running `jupyter lab` (or `jupyter notebook` if you use notebook) here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here.

If using JupyterLab

Installed Labextensions
Config option `kernel_spec_manager_class` not recognized by `ListLabExtensionsApp`.
[W 2024-02-14 21:13:51.921 LabApp] Config option `kernel_spec_manager_class` not recognized by `LabApp`.
JupyterLab v3.6.3
C:\Users\aa\Miniconda3\share\jupyter\labextensions
        jupyter-matplotlib v0.11.3 enabled ok
        jupyterlab_pygments v0.2.2 enabled ok (python, jupyterlab_pygments)
        @jupyter-widgets/jupyterlab-manager v5.0.10 enabled ok (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: C:\Users\aa\Miniconda3\share\jupyter\lab
amine-aboufirass commented 4 months ago

This is a temporary solution I found, but it introduces unnecessary complexity in my opinion:

import ipywidgets as widgets
from IPython.display import display, clear_output

sample_data = {
    "A": [1,4,5,7],
    "B": [123, 452, 546],
    "C": [-23, 23,34, 342, ]
}

dropdown = widgets.Dropdown(options=["A", "B", "C"], description="Value")
output = widgets.Output()
label = widgets.Label(value="test")

def update_label(change):
    label.value = str(change['new'])

def update(change):

    with output:
        clear_output(wait=True)
        slider = widgets.SelectionSlider(options=sample_data[dropdown.value], description='Slider')
        label.value = str(slider.value)
        slider.observe(update_label, 'value')
        display(slider)

dropdown.observe(update, "value")
display(dropdown, output, label)

update(None)  # To display the initial slider
amine-aboufirass commented 3 months ago

@jdfreder Not sure if you're the right person for this but it would be great to get confirmation that this is indeed a bug or whether I'm doing something wrong here. I've already tried to discuss this seemingly major issue at the discourse page but didn't get much response. Thanks for your consideration.