'Python Dash Search for Children and Setting their Values

I just want to know how I can search and set values of children within either a html.Div or another component such as dbc.Spinner. For example, I have declared the following:

msgconsole = dbc.Spinner([
             dbc.Textarea(id='msgconsole',
             invalid=False, size="sm", 
             style={'width': '100%', 'height': 261},
             placeholder="Search Results will be displayed here"
             )
             ], 
             color="primary", type="grow"
            ) 

Now, in my callback I am trying to set the msgconsole textarea to the msgstr I receive as an input:

  app.layout = html.Div([dcc.Location(id="url"), navbar, sidebar, content, 
                   html.Div(id='msgconsolestr', style={'display': 'none'}),
                   html.Div(id='cache', style={'display': 'none'})
                   ])


@app.callback(Output('page-content', 'children'), [Input('url', 'pathname'),
                                           Input('msgconsolestr', 'children'),
                                           Input('cache', 'children')])
def render_page_content(pathname, msgcondata, cached_data):
  if pathname == "/":
    if msgcondata is None:
        print("\nmsgcondata is None")
    else:
        print("\nmsgcondata has a message:\n" + msgcondata)
        msgconsole.children(['msgconsole']).value = msgcondata
            
    return dbc.Container(
            [
              html.H1("Search a Product Code "),
              html.Hr(),
              dbc.Row([
                        dbc.Col(controls, md=4),
                        dbc.Col(msgconsole, md=4)
                      ],
                      align="center",
                      ),
            ],
            fluid=True,
    ) 

Although msgconsole.children(['msgconsole']).value = msgcondata does work first time, however, it then throws an exception:

  msgconsole.children(['msgconsole']).value = msgcondata
  TypeError: 'list' object is not callable
  127.0.0.1 - - [06/May/2022 13:27:05] "POST /_dash-update-component HTTP/1.1" 500

Can you please tell me how to call the child 'msgconsole' which is a textarea and set its value to string.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source