After I added the third output for modal-simple, I started to see this error “Callback function not found for output ‘…xid_selections.options…center_selections.options…’, perhaps you forgot to prepend the ‘@’?”. I’m trying to use this callback to populate the children of dmc.Modal which contains dbpc.Tree component.
dbc.Spinner([
dbc.Row([
#dbc.Col(html.P("XID: ",className='mt-3',style={'font-weight':10,'margin-inline-start':100}),width='1'),
dbc.Col([xid_text := dcc.Dropdown(id = 'xid_selections',
placeholder='Type A XID',
className = 'ms-5 me-2 mt-2',
multi=True)
],width='4'),
#dbc.Col(html.H4("Cost Center: ",className='mt-3',style={}),width='1'),
dbc.Col([center_code_text := dcc.Dropdown(id = 'center_selections',
placeholder='Type A Cost Center',
className = 'me-2 mt-2',
multi=True)
],width='4'),
dbc.Col([oracle_submit_button := dmc.Button("Submit", className = 'mt-2')
],width='3')
],className='mt-2'),
dbc.Row([
dbc.Col(dmc.Button("Hierarchy Browser", id="modal-demo-button"),width='2'),
dmc.Modal(
title="Total Center Hierarchy",
id='modal_simple'
)
],className='mt-3 ms-3')
],color='primary',fullscreen=True),
@callback(
[Output('xid_selections', 'options'),
Output('center_selections', 'options'),
Output('modal_simple', 'children')],
Input('url', 'pathname')
)
def initialize_selectors(pathname):
print(pathname)
if pathname == '/report':
print(pool.busy)
print(os.getpid(), 'Getting XIDS...')
xid_selections = get_all_xids()
print('Getting Centers...')
center_selections = get_all_centers()
print('Getting center hierarchy...')
center_hier = get_center_hier()
print('DONE!')
modal_simple = \
dbpc.Tree(
id='center_tree',
contents=center_hier
),
dmc.Space(h=20),
dmc.Group(
[
dmc.Button("Submit", id="modal-submit-button"),
dmc.Button(
"Close",
color="red",
variant="outline",
id="modal-close-button",
),
],
justify="flex-end",
)
return xid_selections, center_selections, modal_simple
raise PreventUpdate
Also, when I update the code to comment out modal_simple and the output for modal_simple then the app works as expected. So it seems to have something to do with this output.
@callback(
[Output('xid_selections', 'options'),
Output('center_selections', 'options')],
**#Output('modal_simple', 'children')],**
Input('url', 'pathname')
)
def initialize_selectors(pathname):
print(pathname)
if pathname == '/report':
print(pool.busy)
print(os.getpid(), 'Getting XIDS...')
xid_selections = get_all_xids()
print('Getting Centers...')
center_selections = get_all_centers()
print('Getting center hierarchy...')
center_hier = get_center_hier()
print('DONE!')
modal_simple = dbpc.Tree(
id='center_tree',
contents=center_hier
),
dmc.Space(h=20),
dmc.Group(
[
dmc.Button("Submit", id='modal-submit-button'),
dmc.Button(
"Close",
color="red",
variant="outline",
id='modal-close-button',
),
],
justify="flex-end",
)
return xid_selections, center_selections **#, modal_simple**
raise PreventUpdate