{"action":"created","issue":{"url":"https://api.github.com/repos/ipython/ipywidgets/issues/149","labels_url":"https://api.github.com/repos/ipython/ipywidgets/issues/149/labels{/name}","comments_url":"https://api.github.com/repos/ipython/ipywidgets/issues/149/comments","events_url":"https://api.github.com/repos/ipython/ipywidgets/issues/149/events","html_url":"https://github.com/ipython/ipywidgets/pull/149","id":102634901,"number":149,"title":"Add an on_change callback to Selection widgets","user":{"login":"blink1073","id":2096628,"avatar_url":"https://avatars.githubusercontent.com/u/2096628?v=3","gravatar_id":"","url":"https://api.github.com/users/blink1073","html_url":"https://github.com/blink1073","followers_url":"https://api.github.com/users/blink1073/followers","following_url":"https://api.github.com/users/blink1073/following{/other_user}","gists_url":"https://api.github.com/users/blink1073/gists{/gist_id}","starred_url":"https://api.github.com/users/blink1073/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blink1073/subscriptions","organizations_url":"https://api.github.com/users/blink1073/orgs","repos_url":"https://api.github.com/users/blink1073/repos","events_url":"https://api.github.com/users/blink1073/events{/privacy}","received_events_url":"https://api.github.com/users/blink1073/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-23T16:11:38Z","updated_at":"2015-08-24T17:38:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ipython/ipywidgets/pulls/149","html_url":"https://github.com/ipython/ipywidgets/pull/149","diff_url":"https://github.com/ipython/ipywidgets/pull/149.diff","patch_url":"https://github.com/ipython/ipywidgets/pull/149.patch"},"body":"This is similar to the `on_submit` callback for `Text` widgets.\r\n\r\n<img width=\"610\" alt=\"screen shot 2015-08-23 at 11 09 28 am\" src=\"https://cloud.githubusercontent.com/assets/2096628/9429017/b4cc40f4-4987-11e5-8717-a27a74f7bcad.png\">\r\n"},"comment":{"url":"https://api.github.com/repos/ipython/ipywidgets/issues/comments/134312197","html_url":"https://github.com/ipython/ipywidgets/pull/149#issuecomment-134312197","issue_url":"https://api.github.com/repos/ipython/ipywidgets/issues/149","id":134312197,"user":{"login":"jasongrout","id":192614,"avatar_url":"https://avatars.githubusercontent.com/u/192614?v=3","gravatar_id":"","url":"https://api.github.com/users/jasongrout","html_url":"https://github.com/jasongrout","followers_url":"https://api.github.com/users/jasongrout/followers","following_url":"https://api.github.com/users/jasongrout/following{/other_user}","gists_url":"https://api.github.com/users/jasongrout/gists{/gist_id}","starred_url":"https://api.github.com/users/jasongrout/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasongrout/subscriptions","organizations_url":"https://api.github.com/users/jasongrout/orgs","repos_url":"https://api.github.com/users/jasongrout/repos","events_url":"https://api.github.com/users/jasongrout/events{/privacy}","received_events_url":"https://api.github.com/users/jasongrout/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T17:38:40Z","updated_at":"2015-08-24T17:38:40Z","body":"Like this?\r\n\r\n```python\r\n\r\nfrom ipywidgets import Dropdown\r\nfrom IPython.display import display\r\nfrom traitlets import HasTraits, Enum\r\nclass myclass(HasTraits):\r\n    x = Enum(['hello', 'goodbye'], default_value='hello')\r\ndef make_gui(obj, attr, trait):\r\n    def callback(name, new):\r\n        print(\"**changed\", attr, new)\r\n    dd = Dropdown(value=getattr(obj, attr), options=trait.values)\r\n    dd.on_trait_change(callback, 'value')\r\n    return dd\r\n\r\ndef make_editor(obj):    \r\n    for attr, trait in obj.traits().items():\r\n        display(make_gui(obj, attr, trait))\r\n```"}}