forked from plotly/dash
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimple_app.py
38 lines (27 loc) · 905 Bytes
/
simple_app.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
# pylint: disable=missing-docstring
import dash_core_components as dcc
import dash_html_components as html
import dash
from dash.dependencies import Output, Input
from dash.exceptions import PreventUpdate
app = dash.Dash(__name__)
app.layout = html.Div(
[
dcc.Input(id="value", placeholder="my-value"),
html.Div(["You entered: ", html.Span(id="out")]),
html.Button("style-btn", id="style-btn"),
html.Div("style-container", id="style-output"),
]
)
@app.callback(Output("out", "children"), Input("value", "value"))
def on_value(value):
if value is None:
raise PreventUpdate
return value
@app.callback(Output("style-output", "style"), [Input("style-btn", "n_clicks")])
def on_style(value):
if value is None:
raise PreventUpdate
return {"padding": "10px"}
if __name__ == "__main__":
app.run_server(debug=True, port=10850)