{"action":"opened","issue":{"url":"https://api.github.com/repos/eteq/astrowidgets/issues/4","repository_url":"https://api.github.com/repos/eteq/astrowidgets","labels_url":"https://api.github.com/repos/eteq/astrowidgets/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/eteq/astrowidgets/issues/4/comments","events_url":"https://api.github.com/repos/eteq/astrowidgets/issues/4/events","html_url":"https://github.com/eteq/astrowidgets/issues/4","id":346314239,"node_id":"MDU6SXNzdWUzNDYzMTQyMzk=","number":4,"title":"Add this list of features to the viewer","user":{"login":"mwcraig","id":1147167,"node_id":"MDQ6VXNlcjExNDcxNjc=","avatar_url":"https://avatars1.githubusercontent.com/u/1147167?v=4","gravatar_id":"","url":"https://api.github.com/users/mwcraig","html_url":"https://github.com/mwcraig","followers_url":"https://api.github.com/users/mwcraig/followers","following_url":"https://api.github.com/users/mwcraig/following{/other_user}","gists_url":"https://api.github.com/users/mwcraig/gists{/gist_id}","starred_url":"https://api.github.com/users/mwcraig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mwcraig/subscriptions","organizations_url":"https://api.github.com/users/mwcraig/orgs","repos_url":"https://api.github.com/users/mwcraig/repos","events_url":"https://api.github.com/users/mwcraig/events{/privacy}","received_events_url":"https://api.github.com/users/mwcraig/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-07-31T18:51:18Z","updated_at":"2018-07-31T18:51:18Z","closed_at":null,"author_association":"COLLABORATOR","body":"These are my notes from the sprint Saturday night:\r\n\r\n```\r\n# Define a callback that shows the output of a print\r\nout = ipyw.Output()\r\n\r\ndef show_event(viewer, event, datax, datay):\r\n    with out:\r\n       # print(dir(event))\r\n        print(event.data_x, event.data_y)\r\ndisplay(out)\r\n\r\n# This would work for adding markers with the appropriate callback\r\ngvc = w._viewer.get_canvas()\r\ngvc.add_callback('cursor-down', show_event)\r\n\r\n# Changing binds for pan/zoom\r\nbind_map = w._viewer.get_bindmap()\r\n\r\n# ms is click-drag\r\n# kp is keypress\r\n# sc is scroll\r\n# map_event args: mode, modifiers (usually empty), trigger, event_name (last two as strings)\r\nbind_map.map_event(None, (), 'ms_left', 'pan')\r\n\r\n# contrast with right mouse\r\nbind_map.map_event(None, (), 'ms_right', 'contrast')\r\n\r\n# zoom by scrolling\r\nbind_map.map_event(None, (), 'pa_pan', 'zoom')\r\n\r\n# pan by scrolling\r\nbind_map.map_event(None, (), 'pa_pan', 'pan')\r\n\r\n# restore contrast with ctrl-right-click... NOTE TUPLE FOR MODIFIER\r\nbind_map.map_event(None, ('ctrl',), 'ms_right', 'contrast_restore')\r\n\r\n# click to center\r\nbind_map.map_event(None, ('shift',), 'ms_left', 'panset')\r\n\r\n# to bind a custom event to a function of your choosing\r\n\r\nbind_map.map_event(None, (), 'kp_w', 'my_custom_event')\r\n\r\n# Signature of callback_function is\r\ndef callback_function(viewer, event, data_x, data_y, *args):\r\n    with out:\r\n        print('The magic key was pressed')\r\n    pass\r\n\r\n# prefix for keypress is keydown-\r\n# suffix for ms_... is -down\r\n# suffix for sc_... is -scroll\r\nw._viewer.set_callback('keydown-my_custom_event', callback_function)\r\n```"}}
{"actor":{"display_login":"mwcraig"}}