Checkbox tooltips

Hi,

is it possible to have custom tooltips on a list of checkboxes?

The example below will produce a list of checkboxes where the same text is used for both checkbox labels and tooltips.

import ipywidgets as widgets

data = {"key_1":"value_1", "key_2":"value_2", "key_3":"value_3"}

names = []
checkbox_objects = []
for key in data:
    checkbox_objects.append(widgets.Checkbox(value=False, description=key))
    names.append(key)

arg_dict = {names[i]: checkbox for i, checkbox in enumerate(checkbox_objects)}

ui = widgets.VBox(children=checkbox_objects)

selected_data = []
selected_label = []
def select_data(**kwargs):
    selected_data.clear()
    selected_label = []
    for key in kwargs:
        if kwargs[key] is True:
            selected_data.append(key)
            selected_label.append(data[key])
    print(selected_data, selected_label)

out = widgets.interactive_output(select_data, arg_dict)
display(ui, out)
# How to change the tooltip text? 

My aim is to have the checkboxes tooltips render the value_# from the given dict. is that possible?

Each widget needs a description_tooltip=names[i] perhaps?

The full schema docs is a good place to find all of the possible values.

1 Like

I have tried to use:

description_tooltip='some text'

but it gets ignored and the tooltip is always like the text in the description.
simple code to reproduce:

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

The docs claim it defaults to description, so if they don’t, that would be a good one to raise as an issue on the repo!

2 Likes
1 Like