{"action":"opened","issue":{"url":"https://api.github.com/repos/ipython/ipywidgets/issues/621","repository_url":"https://api.github.com/repos/ipython/ipywidgets","labels_url":"https://api.github.com/repos/ipython/ipywidgets/issues/621/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipywidgets/issues/621/comments","events_url":"https://api.github.com/repos/ipython/ipywidgets/issues/621/events","html_url":"https://github.com/ipython/ipywidgets/issues/621","id":157939202,"number":621,"title":"update options on Selection Widget","user":{"login":"marqh","id":1557321,"avatar_url":"https://avatars.githubusercontent.com/u/1557321?v=3","gravatar_id":"","url":"https://api.github.com/users/marqh","html_url":"https://github.com/marqh","followers_url":"https://api.github.com/users/marqh/followers","following_url":"https://api.github.com/users/marqh/following{/other_user}","gists_url":"https://api.github.com/users/marqh/gists{/gist_id}","starred_url":"https://api.github.com/users/marqh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marqh/subscriptions","organizations_url":"https://api.github.com/users/marqh/orgs","repos_url":"https://api.github.com/users/marqh/repos","events_url":"https://api.github.com/users/marqh/events{/privacy}","received_events_url":"https://api.github.com/users/marqh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-01T15:38:11Z","updated_at":"2016-06-01T15:38:11Z","closed_at":null,"body":"I would like to update the options on a selection widget.  this 'just worked' in ipywidgets v4 but v5 has more validation\r\n\r\nI have written what feels like a clumsy work around pattern to enable me to get the functionality I want.  \r\nI would greatly appreciate advice on what I'm trying to achieve and how to do it better\r\n\r\n```\r\nimport ipywidgets\r\nimport IPython\r\nimport numpy as np\r\n\r\nrands = ipywidgets.Dropdown(\r\n    description = 'Random numbers:',\r\n    options = {},\r\n)\r\n\r\nmake_rands = ipywidgets.Button(description='randomise')\r\n\r\ndef randoms(sender):\r\n    rands.options['None'] = None\r\n    rands.value = None\r\n    vals = np.random.random(4)\r\n    options = [(str(r), r) for r in vals]\r\n    rands.options = dict([('None', None)] + options)\r\n    rands.value = options[0][1]\r\n    rands.options = dict(options)\r\n\r\n\r\nmake_rands.on_click(randoms)\r\n\r\nIPython.display.display(rands, make_rands)\r\n```"}}
{"actor":{"display_login":"marqh"}}