Values in input not updating

I am trying to use the

app.layout[' ... '].value 

to return a value.

My code is as follows:

import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()

app.config.supress_callback_exceptions = True

app.layout = html.Div([
    dcc.Input(
        id='datasource',
        value=0,
        type="number"
    ),
    html.Div(id='Value_Display'),
])

@app.callback(
    Output('Value_Display', 'children'),
    [Input('datasource', 'value')])
def display_controls(datasource_value):
    print(app.layout['datasource'].value)
    return datasource_value

if __name__ == '__main__':
    app.run_server(debug=True)

One can see that the value gets updated correctly becasue one can see that the

return datasource_value 

does properly update. However it can be seen that the value that

return datasource_value

and

app.layout['datasource'].value

are different

I am probably either using app.layout[‘datasource’].value wrong or have complelty misunderstood its function.

Any help would be much appreciated, many thanks

Your input is the value of the dropdown, why do you want to use

app.layout[' ... '].value 

specifically?

You can just

@app.callback(
    Output('Value_Display', 'children'),
    [Input('datasource', 'value')])
def display_controls(datasource_value):
    print(datasource_value)
    return datasource_value
```
1 Like

Sorry I should have specified that this is not my code and that in my actual code I am unable to do this. I need to be able to call the value in the way that I have done. (my code here was merely to illustrate my issue.)

My actual issue will be solved if I can call on the value in the way I have specified. Unless it is possible to have a callback within a callback.