{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipywidgets/issues/1091","repository_url":"https://api.github.com/repos/ipython/ipywidgets","labels_url":"https://api.github.com/repos/ipython/ipywidgets/issues/1091/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipywidgets/issues/1091/comments","events_url":"https://api.github.com/repos/ipython/ipywidgets/issues/1091/events","html_url":"https://github.com/ipython/ipywidgets/issues/1091","id":206529124,"number":1091,"title":"ToggleButtons / _Selection .value in Python side != .value on js side","user":{"login":"maartenbreddels","id":1765949,"avatar_url":"https://avatars.githubusercontent.com/u/1765949?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenbreddels","html_url":"https://github.com/maartenbreddels","followers_url":"https://api.github.com/users/maartenbreddels/followers","following_url":"https://api.github.com/users/maartenbreddels/following{/other_user}","gists_url":"https://api.github.com/users/maartenbreddels/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenbreddels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenbreddels/subscriptions","organizations_url":"https://api.github.com/users/maartenbreddels/orgs","repos_url":"https://api.github.com/users/maartenbreddels/repos","events_url":"https://api.github.com/users/maartenbreddels/events{/privacy}","received_events_url":"https://api.github.com/users/maartenbreddels/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-02-09T15:02:33Z","updated_at":"2017-02-09T15:13:04Z","closed_at":null,"body":"Say we have\r\n```\r\ntoggle = ipywidgets.ToggleButtons(options=[(\"One\", 1), (\"Two\", 2)])\r\n```\r\nThen clicking on 'One' will reflect that toggle.value == 1.\r\nHowever, on the js side, value is actually \"One\", which messes things up if you use jslink.\r\nThe problem is I think in SelectView._updateOptions (https://github.com/ipython/ipywidgets/blob/master/jupyter-js-widgets/src/widget_selection.ts#L90)\r\nWhich uses _options_labels for both the label and the data.\r\nMy guess is that on the Python side, both _options_labels and _options_values in ipywidgets._Selection need sync=True as well.\r\nI unfortunately cannot get the dev-install.sh to work, otherwise I might attempt a PR.\r\n\r\nSnippet to reproduce the bug:\r\n```\r\nimport ipywidgets\r\ntoggle = ipywidgets.ToggleButtons(options=[(\"One\", 1), (\"Two\", 2)])\r\nlabel = ipywidgets.Label()\r\nipywidgets.jslink((label, 'value'), (toggle, 'value'))\r\nipywidgets.VBox([toggle, label])\r\n```\r\n\r\nversion info: Python3 / ipywidgets (6, 0, 0, 'beta9')\r\n"},"comment":{"url":"https://api.github.com/repos/ipython/ipywidgets/issues/comments/278670660","html_url":"https://github.com/ipython/ipywidgets/issues/1091#issuecomment-278670660","issue_url":"https://api.github.com/repos/ipython/ipywidgets/issues/1091","id":278670660,"user":{"login":"maartenbreddels","id":1765949,"avatar_url":"https://avatars.githubusercontent.com/u/1765949?v=3","gravatar_id":"","url":"https://api.github.com/users/maartenbreddels","html_url":"https://github.com/maartenbreddels","followers_url":"https://api.github.com/users/maartenbreddels/followers","following_url":"https://api.github.com/users/maartenbreddels/following{/other_user}","gists_url":"https://api.github.com/users/maartenbreddels/gists{/gist_id}","starred_url":"https://api.github.com/users/maartenbreddels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maartenbreddels/subscriptions","organizations_url":"https://api.github.com/users/maartenbreddels/orgs","repos_url":"https://api.github.com/users/maartenbreddels/repos","events_url":"https://api.github.com/users/maartenbreddels/events{/privacy}","received_events_url":"https://api.github.com/users/maartenbreddels/received_events","type":"User","site_admin":false},"created_at":"2017-02-09T15:13:04Z","updated_at":"2017-02-09T15:13:04Z","body":"But the Python's side value is 1, not 'One', so it it not consistent. If toggle.value == 1, I expect the js side to also have 1 as its value, not 'One'."}}
{"actor":{"display_login":"maartenbreddels"}}