Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 以编程方式更新dash_核心组件小部件值_Python_Plotly Dash - Fatal编程技术网

Python 以编程方式更新dash_核心组件小部件值

Python 以编程方式更新dash_核心组件小部件值,python,plotly-dash,Python,Plotly Dash,我是dash的新手,我不知道如何更新一个小部件的值,而不必创建一个函数并用回调和另一个小部件的输入来包装它 import dash from dash.dependencies import Input, Output import dash_core_components as dcc import dash_html_components as html app = dash.Dash() # create radio items widget widget=dcc.RadioItem

我是dash的新手,我不知道如何更新一个小部件的值,而不必创建一个函数并用回调和另一个小部件的输入来包装它

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

app = dash.Dash()

# create radio items widget 
widget=dcc.RadioItems(
        options=[
            {'label': 'New York City', 'value': 'NYC'},
            {'label': 'Montreal', 'value': 'MTL'},
            {'label': 'San Francisco', 'value': 'SF'}
        ],
        value='MTL')

# append this to a html.div children.
div  = html.Div([widget])
app.layout = div

if __name__ == '__main__':
    app.run_server(debug=True)


# normally I would like to be able to update the widget value programmatically and have the html UI updated automatically too
widget.set_value('SF')

感谢您的帮助

您已经找到了答案。对UI的任何更新都将来自回调。您可以让触发回调的
Input
值来自与另一个组件交互的用户,例如单击按钮,或者它可以使用
Interval
组件每x秒更新一次,或者它可以是一系列更新中的一个,每个更新都会侦听之前的一个,最终可能由,用户交互。

谢谢。这是我已经知道的,但我想知道是否可以使用不必触摸界面的直接方法进行更新。这是不可能的。对仪表板组件的任何更改都必须通过回调进行。