Code: Select all
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
# define the layout of the page
app.layout = html.Div([
dcc.Input(id='input', value='Enter something here!', type='text'),
html.Div(id='output')
])
# define the callback function
# this decorator function replaces some called function and performs the actual value update
# the function to update the value must immediately follow this decorator
@app.callback(
# change element marked 'output' whenever element 'input' changes its 'value'
Output(component_id='output', component_property='children'),
[Input(component_id='input', component_property='value')]
)
def update_value(input_data):
return 'Input: "{}"'.format(input_data)
if __name__ == "__main__":
app.run_server(debug=True)