Skip to content

Commit 519143c

Browse files
committed
init file change + example app setup
1 parent 816b6e0 commit 519143c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

crystal_toolkit/apps/examples/LiMnP2O7_mg.json

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
import dash
3+
from dash import html
4+
from dash_mp_components import CrystalToolkitScene
5+
from monty.serialization import loadfn
6+
7+
import crystal_toolkit.components as ctc
8+
from crystal_toolkit.settings import SETTINGS
9+
10+
app = dash.Dash(assets_folder=SETTINGS.ASSETS_PATH)
11+
12+
# create the MigrationGraph object
13+
mg = loadfn("LiMnP2O7_mg.json")
14+
15+
# create the Crystal Toolkit component
16+
# no MigrationGraph component yet
17+
component = ctc.StructureMoleculeComponent(mg.structure, id="my_structure")
18+
test_scene = mg.get_scene()
19+
20+
# example layout
21+
my_layout = html.Div(
22+
[html.Div([CrystalToolkitScene(data=test_scene.to_json())])],
23+
style=dict(
24+
margin="2em auto", display="grid", placeContent="center", placeItems="center"
25+
),
26+
)
27+
28+
# tell crystal toolkit about your app and layout
29+
ctc.register_crystal_toolkit(app, layout=my_layout)
30+
31+
# run this app with "python path/to/this/file.py"
32+
# in production, deploy behind gunicorn or similar
33+
# see Dash documentation for more information
34+
if __name__ == "__main__":
35+
app.run_server(debug=True, port=8050)

crystal_toolkit/renderables/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from crystal_toolkit.renderables.lattice import Lattice as Lattice
2+
from crystal_toolkit.renderables.migrationgraph import MigrationGraph as MigrationGraph
23
from crystal_toolkit.renderables.molecule import Molecule as Molecule
34
from crystal_toolkit.renderables.moleculegraph import MoleculeGraph as MoleculeGraph
45
from crystal_toolkit.renderables.phasediagram import PhaseDiagram as PhaseDiagram

0 commit comments

Comments
 (0)