plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.54k stars 2.08k forks source link

output not being updated by callback #3022

Closed DSAGRO3F closed 1 month ago

DSAGRO3F commented 1 month ago

Thank you so much for helping improve the quality of Dash!

We do our best to catch bugs during the release process, but we rely on your help to find the ones that slip through.

Describe your context Google Colab Pro

Describe the bug

Using app Dash with dcc.Input() callback I noticed output is not updated accordingly. No error message. If I input "hello" in text box, output should be updated to "hello", instead initial value remains.

Expected behavior

If I input "hello" in text box, output should be updated to "hello", instead initial value remains..

Screenshots

app = JupyterDash(__name__)

port = 8053

"""authenticate using token"""
!ngrok config add-authtoken 2S97GELhJsGO---token---koHb24wsr #Configure authtoken

"""Open a ngrok tunnel to the HTTP server"""
public_url = ngrok.connect(port).public_url
print(f'* ngrok tunnel {public_url} -> http://127.0.0.1:{port}')

"""configure app layout"""
app.layout = html.Div(
    children=[
        html.H5('change value in text box'),

        html.Div(["input: ", dcc.Input(id='my-input', value='initial-value', type='text')]),

        html.Div(id='my-output'),
    ])

"""define callback"""
@app.callback(
    Output(component_id='my-output', component_property='children'),
    Input(component_id='my-input', component_property='value')
)
def update_input(text_input):
  return print(f'output: {text_input}')

if __name__ == "__main__":
  app.run_server(debug=False, jupyter_server_url=public_url, port=port, mode='external')
gvwilson commented 1 month ago

@T4rk1n does the example code look good to you?

T4rk1n commented 1 month ago

@DSAGRO3F You are returning print from the callback here:

def update_input(text_input):
  return print(f'output: {text_input}')

print doesn't return anything.

DSAGRO3F commented 1 month ago

Many thanks!