如何将HTML列表添加到仪表板布局

时间:2019-05-01 10:48:04

标签: python plotly plotly-dash

我需要在屏幕上的特定位置并动态地将单词列表添加到短划线布局中(意思是单词列表随时间而变化):

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



app = dash.Dash(__name__)


trends =['python', 'flask', 'jave']

html_lists = []


trends =['python', 'flask', 'jave']

app.layout = html.Div(
    html.Div(
        className="trend",
        children=[
            html.Ui(
                for i in trends:
                    html.Li(i))
        ], )
    )
print(html_ul_list)
if __name__ == '__main__':
    app.run_server(debug=True)

我需要在网页上显示输出,如屏幕右侧所示:

趋势

  • python
  • java a

  • 以此类推...

1 个答案:

答案 0 :(得分:1)

您有几个小错误。我对此进行了测试,并且有效:

app = dash.Dash(__name__)

trends = ['python', 'flask', 'java']

app.layout = html.Div(
    html.Div(
        className="trend",
        children=[
            html.Ul(id='my-list', children=[html.Li(i) for i in trends])
        ],
    )
)

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

要使该列表动态更新,您需要连接一个回调,其输出如下:Output('my-list', 'children')。回调将带给您的输入内容可能已经知道,但这并不属于您的帖子,因此我将其省略。