-
Notifications
You must be signed in to change notification settings - Fork 0
/
testwidget.py
46 lines (35 loc) · 1.35 KB
/
testwidget.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from widget_jsmol import WidgetJmol
import ipywidgets as widgets
w = WidgetJmol()
display(w)
load_button = widgets.Button(description = 'Load Structure')
rotate_button = widgets.Button(description = 'Rotate')
invert_button = widgets.Button(description = 'Invert')
rotoinversion_button = widgets.Button(description = 'Rotoinversion')
reset_button = widgets.Button(description = 'Reset')
symops_button = widgets.Button(description = 'List All SymOps')
out = widgets.Output()
def load_structure(self):
with out:
w.script = 'load http://localhost:8888/tree/Crystallography/jmol_AMS_DATA_(2).cif'
def rotate(self):
with out:
w.script = 'rotate y 90 90'
def invert(self):
with out:
w.script = 'invertSelected'
def rotoinversion(self):
with out:
w.script = 'rotate y 90 90; delay 0.5; invertSelected'
def symops(self):
with out:
w.script = 'show SYMOP'
load_button.on_click(load_structure)
rotate_button.on_click(rotate)
invert_button.on_click(invert)
rotoinversion_button.on_click(rotoinversion)
reset_button.on_click(load_structure)
symops_button.on_click(symops)
bottom_row = widgets.HBox([rotate_button, invert_button, rotoinversion_button, out])
top_row = widgets.HBox([load_button, reset_button, out])
widgets.VBox([top_row, bottom_row])