PlotlyDash:3个回调,调用相同的输入列表2,1n

2024-09-30 10:26:51 发布

您现在位置:Python中文网/ 问答频道 /正文

3个具有相同输入列表的回调,2个被调用,但不是1个。在调试器中,对于第3个通知,执行从输入列表直接跳出函数。任何建议欢迎。。。你知道吗

@app.callback(
    dash.dependencies.Output('firstcallback', 'children'),
    [dash.dependencies.Input('firstdropdown', 'value'),
     dash.dependencies.Input('seconddropdown', 'value')])
def firstgoodcallback(first, second):
    print("firstgoodcallback") #prints ok
    return u'{} is a reference to {}'.format(first, second)

@app.callback(
    dash.dependencies.Output('secondcallback', 'children'),
    [dash.dependencies.Input('firstdropdown', 'value'),
     dash.dependencies.Input('seconddropdown', 'value')])
def secondgoodcallback(first, second):
    print("secondgoodcallback") #prints ok
    return u'{} is a second reference to {}'.format(first, second)

@app.callback(
    dash.dependencies.Output('thirdcallback', 'children'),
    [dash.dependencies.Input('firstdropdown', 'value'),
     dash.dependencies.Input('seconddropdown', 'value')])
def set_display_children(first, second):
    print("helloWorld") #doesn't get this far    
    return u'{} is a third reference to {}'.format(first, second)

而且'firstdropdown''seconddropdown'在启动时都用默认值初始化,并且所有回调都在同一个模块中,该模块也有name==main保护。谢谢


Tags: appinputoutputreturnvaluedefcallbackdependencies

热门问题