File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed
crystal_toolkit/apps/examples Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 4
4
5
5
# standard Dash imports for callbacks (interactivity)
6
6
from dash .dependencies import Input , Output
7
- from dash .exceptions import PreventUpdate
8
7
from pymatgen .core .lattice import Lattice
9
8
from pymatgen .core .structure import Structure
10
9
11
10
import crystal_toolkit .components as ctc
12
11
13
- app = dash .Dash ()
12
+ app = dash .Dash (
13
+ prevent_initial_callbacks = True , # don't run callbacks on page load
14
+ )
14
15
15
16
# now we give a list of structures to pick from
16
17
structures = [
30
31
31
32
ctc .register_crystal_toolkit (app = app , layout = my_layout )
32
33
34
+
33
35
# for the interactivity, we use a standard Dash callback
34
36
@app .callback (
35
37
Output (structure_component .id (), "data" ),
36
38
[Input ("change_structure_button" , "n_clicks" )],
37
39
)
38
40
def update_structure (n_clicks ):
39
- # on load, n_clicks will be None, and no update is required
40
- # after clicking on the button, n_clicks will be an int and incremented
41
- if not n_clicks :
42
- raise PreventUpdate
43
41
return structures [n_clicks % 2 ]
44
42
45
43
You can’t perform that action at this time.
0 commit comments