jupyter-widgets / ipywidgets

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

custom tooltip on checkboxes #3440

Open epifanio opened 2 years ago

epifanio commented 2 years ago

Description

Attempting to add a tooltip to a checkbox, I can't modify the default value. The docs claim it defaults to description - but can be changed by using the description_tooltip attribute.

Reproduce

import ipywidgets as widgets
widgets.Checkbox(value=False, description='key', description_tooltip='val')

Expected behavior

toltip rendering the string 'var' and the checkbox label rendering the string 'key' -- instead the tooltip is rendering the string "key" (seems it uses the default value from the description attribute and ignores the supplied description_tooltip )

Context

Troubleshoot Output

```
$PATH:
    /usr/local/sbin
    /usr/local/bin
    /usr/sbin
    /usr/bin
    /sbin
    /bin

sys.path:
    /usr/local/bin
    /usr/lib/python38.zip
    /usr/lib/python3.8
    /usr/lib/python3.8/lib-dynload
    /usr/local/lib/python3.8/dist-packages
    /usr/lib/python3/dist-packages
    /usr/lib/python3.8/dist-packages

sys.executable:
    /usr/bin/python3

sys.version:
    3.8.5 (default, Jul 28 2020, 12:59:40) 
    [GCC 9.3.0]

platform.platform():
    Linux-5.13.0-37-generic-x86_64-with-glibc2.29

which -a jupyter:
    /usr/local/bin/jupyter

pip list:
    Package                   Version
    ------------------------- -----------------------
    affine                    2.3.0
    aiohttp                   3.7.3
    aiohttp-cors              0.7.0
    aioredis                  1.3.1
    ansiwrap                  0.8.4
    anyio                     2.0.2
    appdirs                   1.4.4
    argon2-cffi               20.1.0
    asciitree                 0.3.3
    async-generator           1.10
    async-timeout             3.0.1
    atomicwrites              1.1.5
    attrs                     19.3.0
    autopep8                  1.5.4
    backcall                  0.2.0
    bcrypt                    3.2.0
    beautifulsoup4            4.8.2
    black                     20.8b1
    bleach                    3.2.1
    blessings                 1.7
    blosc                     1.7.0
    bokeh                     2.2.3
    Bottleneck                1.2.1
    branca                    0.4.1
    bump2version              1.0.1
    bumpversion               0.6.0
    cachetools                4.2.0
    Cartopy                   0.17.0
    certifi                   2019.11.28
    cf-xarray                 0.3.1
    cffi                      1.14.4
    cfgrib                    0.9.8.5
    cftime                    1.1.0
    chardet                   3.0.4
    click                     7.1.2
    click-plugins             1.1.1
    cligj                     0.5.0
    cloudpickle               1.3.0
    colorama                  0.4.3
    colorcet                  2.0.2
    colorful                  0.5.4
    configparser              5.0.1
    confuse                   1.4.0
    contextlib2               0.6.0.post1
    coverage                  5.3.1
    cryptography              3.3.1
    cycler                    0.10.0
    Cython                    0.29.21
    dask                      2.8.1+dfsg
    datashader                0.11.1
    datashape                 0.5.2
    decorator                 4.4.2
    defusedxml                0.6.0
    Deprecated                1.2.10
    distlib                   0.3.1
    distributed               2.9.0
    distro                    1.5.0
    docopt                    0.6.2
    docstring-parser          0.7.3
    docutils                  0.16
    elvis                     0.2
    elyra                     1.5.2
    entrypoints               0.3
    et-xmlfile                1.0.1
    fasteners                 0.14.1
    fastparquet               0.4.1
    feather-format            0.4.1
    filelock                  3.0.12
    Fiona                     1.8.18
    flake8                    3.8.4
    fsspec                    0.6.1
    GDAL                      3.0.4
    Geohash                   1.0
    geojson                   2.5.0
    geolinks                  0.2.0
    geopandas                 0.8.1
    geoviews                  1.8.1
    gitdb                     4.0.5
    GitPython                 3.1.11
    google                    3.0.0
    google-api-core           1.24.1
    google-auth               1.24.0
    google-cloud-core         1.5.0
    google-cloud-storage      1.35.0
    google-crc32c             1.1.0
    google-resumable-media    1.2.0
    googleapis-common-protos  1.52.0
    gpustat                   0.6.0
    grass-session             0.5
    grpcio                    1.34.0
    h5netcdf                  0.7.1
    h5py                      2.10.0
    HeapDict                  1.0.1
    hiredis                   1.1.0
    holoviews                 1.14.0
    html5lib                  1.0.1
    hvplot                    0.7.0
    idna                      2.8
    importlib-metadata        1.5.0
    ipycallback               0.2.5
    ipydatetime               1.1.1
    ipykernel                 5.4.2
    ipylab                    0.3.0
    ipylayout                 0.1.6
    ipyleaflet                0.13.3
    ipympl                    0.5.8
    ipysheet                  0.4.4
    ipyspin                   0.1.2
    ipython                   7.19.0
    ipython-genutils          0.2.0
    ipywidgets                7.7.0
    ipywidgets-bokeh          1.0.2
    isodate                   0.6.0
    isort                     5.6.4
    itsdangerous              1.1.0
    jdcal                     1.0
    jedi                      0.17.2
    jeepney                   0.6.0
    Jinja2                    2.11.2
    json2html                 1.3.0
    json5                     0.9.5
    jsonschema                3.2.0
    jupyter                   1.0.0
    jupyter-bokeh             2.0.4
    jupyter-client            6.1.7
    jupyter-console           6.2.0
    jupyter-core              4.7.0
    jupyter-server            1.1.1
    jupyter-server-proxy      1.5.2
    jupyterlab                2.2.9
    jupyterlab-code-formatter 1.3.8
    jupyterlab-git            0.23.1
    jupyterlab-pygments       0.1.2
    jupyterlab-server         1.2.0
    jupyterlab-widgets        1.1.0
    jupyterlab-zenodo         0.2.0
    keyring                   21.5.0
    kfp                       1.1.2
    kfp-notebook              0.17.0
    kfp-pipeline-spec         0.1.3.1
    kfp-server-api            1.2.0
    kiwisolver                1.0.1
    kubernetes                11.0.0
    llvmlite                  0.35.0
    locket                    0.2.0
    lxml                      4.5.0
    Markdown                  3.3.3
    MarkupSafe                1.1.0
    matplotlib                3.1.2
    mccabe                    0.6.1
    mercantile                1.1.6
    minio                     6.0.2
    mistune                   0.8.4
    monotonic                 1.5
    more-itertools            4.2.0
    mpi4py                    3.0.3
    msgpack                   1.0.2
    multidict                 5.1.0
    multipledispatch          0.6.0
    munch                     2.5.0
    mypy-extensions           0.4.3
    nbclient                  0.5.1
    nbconvert                 5.6.1
    nbdime                    2.1.0
    nbformat                  5.0.8
    nbresuse                  0.4.0
    nc-time-axis              1.2.0
    nest-asyncio              1.4.3
    netCDF4                   1.5.3
    networkx                  2.5
    notebook                  6.1.5
    numba                     0.52.0
    numcodecs                 0.0.0
    numexpr                   2.7.1
    numpy                     1.17.4
    nvidia-ml-py3             7.352.0
    oauthlib                  3.1.0
    olefile                   0.46
    opencensus                0.7.11
    opencensus-context        0.1.2
    openlocationcode          1.0.1
    openpyxl                  3.0.3
    osm2geojson               0.1.28
    OWSLib                    0.19.1
    packaging                 20.3
    pandas                    0.25.3
    pandocfilters             1.4.3
    panel                     0.11.0a3.post2+g5aa0c91
    papermill                 2.2.2
    param                     1.10.0
    paramiko                  2.7.2
    parmap                    1.5.2
    parso                     0.7.1
    partd                     1.0.0
    pathspec                  0.8.1
    PDAL                      2.3.6
    pexpect                   4.8.0
    pickleshare               0.7.5
    Pillow                    8.0.1
    Pint                      0.16.1
    pip                       20.3.3
    pkginfo                   1.6.1
    plotly                    4.14.1
    pluggy                    0.13.0
    prometheus-client         0.9.0
    prompt-toolkit            3.0.8
    protobuf                  3.14.0
    prov                      2.0.0
    PseudoNetCDF              3.1.0
    psutil                    5.8.0
    ptyprocess                0.6.0
    py                        1.8.1
    py-spy                    0.3.3
    pyarrow                   2.0.0
    pyasn1                    0.4.8
    pyasn1-modules            0.2.8
    pycodestyle               2.6.0
    pycparser                 2.20
    pycsw                     2.6.0
    pyct                      0.4.6
    pydeck                    0.5.0
    pydot                     1.4.1
    pyflakes                  2.2.0
    pygeometa                 0.5.0
    Pygments                  2.7.3
    PyNaCl                    1.4.0
    pyparsing                 2.4.6
    pyproj                    2.5.0
    pyrsistent                0.17.3
    pyshp                     2.1.0
    pysolr                    3.9.0
    pytest                    4.6.9
    python-dateutil           2.7.3
    python-geohash            0.8.5
    python-slugify            4.0.1
    pytz                      2019.3
    pyviz-comms               0.7.6
    PyYAML                    5.3.1
    pyzmq                     18.1.1
    qtconsole                 5.0.1
    QtPy                      1.9.0
    rasterio                  1.1.3
    ray                       1.0.1.post1
    rdflib                    5.0.0
    rdflib-jsonld             0.5.0
    readme-renderer           28.0
    rechunker                 0.3.2
    redis                     3.4.1
    regex                     2020.11.13
    requests                  2.22.0
    requests-oauthlib         1.3.0
    requests-toolbelt         0.9.1
    retrying                  1.3.3
    rfc3986                   1.4.0
    rfc3986-validator         0.1.1
    rioxarray                 0.1.1
    rsa                       4.6
    schema                    0.7.2
    scikit-build              0.11.1
    scipy                     1.3.3
    seaborn                   0.11.1
    SecretStorage             3.3.0
    Send2Trash                1.5.0
    setuptools                51.1.0.post20201221
    Shapely                   1.7.0
    shortid                   0.1.2
    sidecar                   0.4.0
    simpervisor               0.3
    simplejson                3.16.0
    six                       1.14.0
    smmap                     3.0.4
    sniffio                   1.2.0
    snuggs                    1.4.7
    sortedcontainers          2.3.0
    soupsieve                 1.9.5
    sparse                    0.11.2
    spatialpandas             0.3.6
    strip-hints               0.1.9
    tables                    3.6.1
    tabulate                  0.8.7
    tblib                     1.7.0
    tenacity                  6.3.1
    terminado                 0.9.1
    testpath                  0.4.4
    text-unidecode            1.3
    textwrap3                 0.9.2
    thrift                    0.13.0
    toml                      0.10.2
    toolz                     0.9.0
    tornado                   6.1
    tox                       3.20.1
    tqdm                      4.54.1
    traitlets                 5.0.5
    traittypes                0.2.1
    twine                     3.2.0
    typed-ast                 1.4.1
    typing-extensions         3.7.4.3
    urllib3                   1.25.8
    virtualenv                20.2.2
    voila                     0.2.4
    watchdog                  1.0.2
    wcwidth                   0.1.8
    webencodings              0.5.1
    websocket-client          0.57.0
    wheel                     0.34.2
    widgetsnbextension        3.6.0
    wrapt                     1.12.1
    xarray                    0.15.0
    xarray-leaflet            0.1.13
    xlrd                      1.1.0
    xlwt                      1.3.0
    xmltodict                 0.12.0
    xtrude                    0.1.2
    yarl                      1.6.3
    zarr                      0.0.0
    zict                      2.0.0
    zipp                      1.0.0
```

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
JupyterLab v2.2.9
Known labextensions:
   app dir: /usr/local/share/jupyter/lab
        @almond-sh/jupyterlab_variableinspector v0.4.1  enabled  OK
        @aquirdturtle/collapsible_headings v2.2.0  enabled  OK
        @bokeh/jupyter_bokeh v2.0.4  enabled  OK
        @chameleoncloud/jupyterlab_zenodo v2.0.0  enabled  OK
        @elyra/code-snippet-extension v1.5.2  enabled  OK
        @elyra/metadata-extension v1.5.2  enabled  OK
        @elyra/pipeline-editor-extension v1.5.2  enabled  OK
        @elyra/python-editor-extension v1.5.2  enabled  OK
        @elyra/theme-extension v1.5.2  enabled  OK
        @ijmbarr/jupyterlab_spellchecker v0.2.0  enabled  OK
        @jupyter-voila/jupyterlab-preview v1.1.0  enabled  OK
        @jupyter-widgets/jupyterlab-manager v2.0.0  enabled  OK
        @jupyter-widgets/jupyterlab-sidecar v0.5.0  enabled  OK
        @jupyterlab/geojson-extension v2.0.1  enabled  OK
        @jupyterlab/git v0.23.1  enabled  OK
        @jupyterlab/mathjax3-extension v3.0.0  enabled  OK
        @jupyterlab/toc v4.0.0  enabled  OK
        @krassowski/jupyterlab_go_to_definition v1.0.0  enabled  OK
        @oriolmirosa/jupyterlab_materialdarker v0.5.0  enabled  OK
        @pyviz/jupyterlab_pyviz v1.0.4  enabled  OK
        @ryantam626/jupyterlab_code_formatter v1.3.8  enabled  OK
        @telamonian/theme-darcula v2.0.0  enabled  OK
        ipycallback v0.2.5  enabled  OK
        ipylab v0.3.0  enabled  OK
        ipylayout v0.1.6  enabled  OK
        ipysheet v0.4.4  enabled  OK
        ipyspin v0.1.2  enabled  OK
        jupyter-leaflet v0.13.2  enabled  OK
        jupyter-matplotlib v0.7.4  enabled  OK
        jupyter-widget-datetime v1.1.1  enabled  OK
        jupyterlab-control v1.1.1  enabled  OK
        jupyterlab-drawio v0.7.0  enabled  OK
        jupyterlab-favorites v2.0.0  enabled  OK
        jupyterlab-recents v2.0.0  enabled  OK
        nbdime-jupyterlab v2.0.1  enabled  OK

Disabled core extensions:
    @jupyterlab/launcher-extension
BotScutters commented 2 years ago

I'm encountering this issue as well. Is anybody working on this or have thoughts on how to fix it? I've tried poking around in the code but I'm not seeing the solution.

janfrederik commented 1 year ago

This issue persists in version 8.1.0, even using the non-deprecated tooltip attribute:

import ipywidgets as widgets
widgets.Checkbox(value=False, description='Short descr', tooltip='Some extra explanation')

This gives the following result, when I hover over the checkbox itself or over the text.

image