1

Is it possible to use multiple inputs to my dash plotly callback, but only have one trigger the callback? It doesn't seem so.

I want to trigger the callback only when a button is pressed. I don't know how to get the other data I need within the callback function if I don't pass it as one of the inputs.

This runs if I "get_file" changes, even if "Button" is not clicked

@app.callback(
    Output("file_to_upload", "children"),
    [Input("Button", "n_clicks"),
     Input("get_file", "filename"), 
     Input("get_file", "contents")]
)
def get_query_file(n_clicks, uploaded_filenames, uploaded_file_contents):

This doesn't work because I need the filename and content within the function

@app.callback(
    Output("file_to_upload", "children"),
    [Input("Button", "n_clicks")]
)
def get_query_file(n_clicks):

1 Answer 1

2

welcome to Dash. Try putting your git_files into a State argument instead of Input, like so:

@app.callback(
Output("file_to_upload", "children"),
Input("Button", "n_clicks"),
[State("get_file", "filename"), 
State("get_file", "contents")]
)
def get_query_file(n_clicks, uploaded_filenames, uploaded_file_contents):
Sign up to request clarification or add additional context in comments.

1 Comment

Note that States takes information but does not trigger the callback like Input does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.