簡體   English   中英

Python + Dash + Bootstrap

[英]Python + Dash + Bootstrap

我正在嘗試在函數中“Pythonify”卡片生成,但它似乎沒有彈出。 也許我做錯了什么,或者我正在構建的儀表板需要非常垂直。 基本上, cardify函數不會生成卡片。

我在這里先向您的幫助表示感謝!


import dash
import dash_bootstrap_components as dbc
import dash_html_components as html

app = dash.Dash(external_stylesheets=[dbc.themes.MINTY])

def cardify(metricname, metricvalue, recapstring):
    dbc.Card(
        [
            dbc.CardBody(
                [
                    html.H2(metricname, className="card-title"),
                    html.H4(metricvalue, className="card-title"),
                    html.P(
                        recapstring,
                        className="card-text",
                    ),
                ]
            ),
        ],
#        style={"width": "18rem"},
        )

app.layout =  \
html.Div(
    [
        dbc.Row(
            [
                dbc.Col(
                    cardify("Card Title", "Metric Value", "Some Quick Example yada yada"),
                    width={"size": 2, "order": 1, "offset": 1},
                ),
                dbc.Col(
                    dbc.Card(
                    [
                        dbc.CardBody(
                            [
                                html.H4("Card title", className="card-title"),
                                html.P(
                                    "Some quick example text to build on the card title and "
                                    "make up the bulk of the card's content.",
                                    className="card-text",
                                ),
                            ]
                        ),
                    ],
#                    style={"width": "18rem"},
                    ),
                    width={"size": 2, "order": 2},
                )           
            ]
        ),
    ]
)
if __name__ == "__main__":
    app.run_server(debug=True)

您的函數cardify需要返回dbc.Card

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM