Skip to content

Commit 1a595bf

Browse files
committed
tweak structure and pourbaix example css
1 parent a7ec219 commit 1a595bf

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

crystal_toolkit/apps/examples/pourbaix.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@
2626
html.Button("Get Pourbaix Diagram", id="get-pourbaix"),
2727
pourbaix_component.layout(),
2828
html.Div(id="pourbaix-output"),
29-
]
29+
],
30+
style=dict(maxWidth="90vw", margin="2em auto"),
3031
)
3132

3233
ctc.register_crystal_toolkit(app=app, layout=my_layout)
3334

34-
# allow app to be run using "python structure.py"
35+
# allow app to be run using "python pourbaix.py"
3536
# in production, deploy behind gunicorn or similar
3637
# see Dash documentation for more information
3738
if __name__ == "__main__":

crystal_toolkit/apps/examples/structure.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
[
2525
html.H1("StructureMoleculeComponent Example"),
2626
html.H2("Standard Layout"),
27-
structure_component.layout(size="400px"),
27+
structure_component.layout(),
2828
html.H2("Optional Title Layout"),
2929
structure_component.title_layout(),
30-
]
30+
],
31+
style=dict(
32+
margin="2em auto", display="grid", placeContent="center", placeItems="center"
33+
),
3134
)
3235

3336
# tell crystal toolkit about your app and layout

crystal_toolkit/apps/examples/write_structure_screenshot_to_file.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import dash
88
from dash import dcc, html
99
from dash.dependencies import Input, Output, State
10+
from pymatgen.ext.matproj import MPRester
1011
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
1112

1213
import crystal_toolkit.components as ctc
@@ -48,7 +49,13 @@ def trigger_image_request(data):
4849

4950
@app.callback(Output(structure_component.id(), "data"), [Input("url", "pathname")])
5051
def trigger_new_data(url):
51-
return get_structure_for_mpid(url[1:])
52+
53+
mp_id = url[1:]
54+
with MPRester() as mpr:
55+
structure = mpr.get_structure_by_material_id(mp_id)
56+
57+
structure = SpacegroupAnalyzer(structure).get_conventional_standard_structure()
58+
return structure
5259

5360

5461
@app.callback(

0 commit comments

Comments
 (0)