forked from google/neuroglancer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample_action.py
30 lines (24 loc) · 939 Bytes
/
example_action.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import argparse
import webbrowser
import neuroglancer
import neuroglancer.cli
if __name__ == "__main__":
ap = argparse.ArgumentParser()
neuroglancer.cli.add_server_arguments(ap)
args = ap.parse_args()
neuroglancer.cli.handle_server_arguments(args)
viewer = neuroglancer.Viewer()
with viewer.txn() as s:
s.layers["image"] = neuroglancer.ImageLayer(
source="precomputed://gs://neuroglancer-public-data/flyem_fib-25/image",
)
def my_action(s):
print("Got my-action")
print(f" Mouse position: {s.mouse_voxel_coordinates}")
print(f" Layer selected values: {s.selected_values}")
viewer.actions.add("my-action", my_action)
with viewer.config_state.txn() as s:
s.input_event_bindings.viewer["keyt"] = "my-action"
s.status_messages["hello"] = "Welcome to this example"
print(viewer)
webbrowser.open_new(viewer.get_viewer_url())