Python+;破折号+;独自创立

Python+;破折号+;独自创立,python,css,bootstrap-4,plotly-dash,Python,Css,Bootstrap 4,Plotly Dash,我试图在函数中“Pythonify”生成卡,但它似乎没有出现。也许我做错了什么,或者我正在构建的仪表板需要非常垂直。基本上,cardfy函数不会生成卡片 提前谢谢你的帮助 import dash import dash_bootstrap_components as dbc import dash_html_components as html app = dash.Dash(external_stylesheets=[dbc.themes.MINTY]) def cardify(metr

我试图在函数中“Pythonify”生成卡,但它似乎没有出现。也许我做错了什么,或者我正在构建的仪表板需要非常垂直。基本上,cardfy函数不会生成卡片

提前谢谢你的帮助


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

是!::脸掌::