0

Thank you for the attention

I can't resolve this hidden problem during a few days and I got to the point of despair and I don't know what to do.

In my dashbroad i would like to add #1 callback which works like #2 callback. The problem is that second callback works fine, but first callback program even doesn't handling when i change value of input_database_name_SELL_vs_BUY component of course. There is no any errors :( I have checked all names and did't find any mistakes

By the way, in case of code below both callback doesn't work

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


app = dash.Dash(__name__)

app.layout = html.Div(
    id='layout',
    children=[
        html.H1(id="intensity_div", children='Intensity scale plot'),
        html.H3(children='Plot the intensity for the day'),
        html.Table(
            [html.Tr([html.Td(html.Table(
                # Header
                [html.Tr([html.Th('Option'), html.Th('Value')])] +
                # Body
                [html.Tr([html.Td('database name'), dcc.Input(id="input_database_name", type='text', placeholder="database name", list='datalist_of_databases', min=1, debounce=False)])] +
                [html.Tr([html.Td('day input'), dcc.Input(id="input_day", type='text', min=1, debounce=True, list='datalist_of_tables_intensity')])] +
                [html.Tr([html.Td('seconds input'), dcc.Input(id="input_seconds", type='number', placeholder="input seconds interval", min=1, debounce=True, value=1)])] +
                [html.Button(id='button_сalculate', disabled=False, children='Calculate')] +
                [html.Tr([html.Td('AVG ALL =', id='avg_all'), html.Td('AVG UPDATE =', id='avg_upd')])] +
                [html.Tr([html.Td('AVG DEL =', id='avg_del'), html.Td('AVG INSERT =', id='avg_ins')])]
            )), dcc.Graph(id='intensity_graph',)])
        ], style={'width': "100%"}),

        # SELL_vs_BUY block
        html.Table(
            [html.Tr([html.Td(html.Table(
                # Header
                [html.Tr([html.Th('Option'), html.Th('Value')])] +
                # Body
                [html.Tr([html.Td('database name'), dcc.Input(id="input_database_name_SELL_vs_BUY", type='text', placeholder="database name", list='datalist_of_databases', min=1, debounce=False)])] +
                [html.Tr([html.Td('day input'), dcc.Input(id="input_day_SELL_vs_BUY", type='text', min=1, debounce=True, list='datalist_of_tables_sell_vs_buy')])] +
                [html.Tr([html.Td('number of levels'), dcc.Input(id="number_of_levels_SELL_vs_BUY",  type='number', placeholder="500", min=0, debounce=True, step=500, value=500)])] +
                [html.Tr([html.Td('step size of level'), dcc.Input(id="step_size_of_level_SELL_vs_BUY",  type='number', placeholder="0.5", min=0.5, debounce=True, step=0.5, value=0.5)])] +
                [html.Button(id='button_calculate_SELL_vs_BUY', disabled=False, children='Calculate')]
            )), dcc.Graph(id='SELL_vs_BUY_graph',)])
        ], style={'width': "100%"}),
])

#1
@app.callback([Output('layout', 'children')],
              [Input('input_database_name_SELL_vs_BUY', 'value')],
              [State('layout', 'children')])
def get_list_of_tables_sell_vs_buy(input_database_name, old_output):
    print('1111')
    if input_database_name:
        pass
    return dash.no_update

#2
@app.callback([Output('layout', 'children')],
              [Input('input_database_name', 'value')],
              [State('layout', 'children')])
def get_list_of_tables_intensity(input_database_name, old_output):
    print('2222')
    if input_database_name:
        pass
    return dash.no_update


if __name__ == '__main__':
    app.run_server(debug=False, port=8051)

I use dash==1.21.0, i am going to use more modern version now.. In 2.0.0 it doesn't work too...

Without State it doesn't work too

I created issue about possible bug

0

1 Answer 1

1

No errors are shown because you're running with debug set to False. If you set debug to True dash tells us what the error is:

Duplicate callback outputs
In the callback for output(s): layout.children Output 0 (layout.children) is already in use. Any given output can only have one callback that sets it. To resolve this situation, try combining these into one callback function, distinguishing the trigger by using dash.callback_context if necessary.

Now I'm not exactly sure what you're trying to do, but like the message above says, try combining your callback function or restructure your app in a way where you don't use the same output multiple times.

Sign up to request clarification or add additional context in comments.

2 Comments

THANK YOU VERY MUCH! Sorry for this child mistake
No problem, glad to help. Btw you can accept an answer to your question if you feel it answers your question. When you reach 15 reputation you will also be able to upvote questions and answers.

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.