Skip to content

ToggleButtons / _Selection .value in Python side != .value on js side #1091

@maartenbreddels

Description

@maartenbreddels

Say we have

toggle = ipywidgets.ToggleButtons(options=[("One", 1), ("Two", 2)])

Then clicking on 'One' will reflect that toggle.value == 1.
However, on the js side, value is actually "One", which messes things up if you use jslink.
The problem is I think in SelectView._updateOptions (https://github.com/ipython/ipywidgets/blob/master/jupyter-js-widgets/src/widget_selection.ts#L90)
Which uses _options_labels for both the label and the data.
My guess is that on the Python side, both _options_labels and _options_values in ipywidgets._Selection need sync=True as well.
I unfortunately cannot get the dev-install.sh to work, otherwise I might attempt a PR.

Snippet to reproduce the bug:

import ipywidgets
toggle = ipywidgets.ToggleButtons(options=[("One", 1), ("Two", 2)])
label = ipywidgets.Label()
ipywidgets.jslink((label, 'value'), (toggle, 'value'))
ipywidgets.VBox([toggle, label])

version info: Python3 / ipywidgets (6, 0, 0, 'beta9')

Metadata

Metadata

Assignees

Labels

resolved-lockedClosed issues are locked after 30 days inactivity. Please open a new issue for related discussion.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions