astropy / astropy/astrowidgets
Add this list of features to the viewer
- Dominant language
- Python
- Stars
- 34
- Forks
- 19
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 4
Description
These are my notes from the sprint Saturday night:
```python
# Define a callback that shows the output of a print
out = ipyw.Output()
def show_event(viewer, event, datax, datay):
with out:
# print(dir(event))
print(event.data_x, event.data_y)
display(out)
# This would work for adding markers with the appropriate callback
gvc = w._viewer.get_canvas()
gvc.add_callback('cursor-down', show_event)
# Changing binds for pan/zoom
bind_map = w._viewer.get_bindmap()
# ms is click-drag
# kp is keypress
# sc is scroll
# map_event args: mode, modifiers (usually empty), trigger, event_name (last two as strings)
bind_map.map_event(None, (), 'ms_left', 'pan')
# contrast with right mouse
bind_map.map_event(None, (), 'ms_right', 'contrast')
# zoom by scrolling
bind_map.map_event(None, (), 'pa_pan', 'zoom')
# pan by scrolling
bind_map.map_event(None, (), 'pa_pan', 'pan')
# restore contrast with ctrl-right-click... NOTE TUPLE FOR MODIFIER
bind_map.map_event(None, ('ctrl',), 'ms_right', 'contrast_restore')
# click to center
bind_map.map_event(None, ('shift',), 'ms_left', 'panset')
# to bind a custom event to a function of your choosing
bind_map.map_event(None, (), 'kp_w', 'my_custom_event')
# Signature of callback_function is
def callback_function(viewer, event, data_x, data_y, *args):
with out:
print('The magic key was pressed')
pass
# prefix for keypress is keydown-
# suffix for ms_... is -down
# suffix for sc_... is -scroll
w._viewer.set_callback('keydown-my_custom_event', callback_function)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the examples around w._viewer.get_canvas(), get_bindmap(), and set_callback(), then determine how the viewer currently handles these interactions. Clarify which features from the code block are required and define done as the selected callbacks, mouse and key bindings, and viewer behaviors being available and verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- jupyter-notebook, python
- Domain
- data-visualization, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100