将带有外部链接的按钮添加到 plotly dash modal

Adding buttons with external links to plotly dash modal

dash 的新手,试图弄清楚如何创建一个内部有自己的按钮的模式(弹出窗口 window)。我已经阅读了 dbc 文档,他们似乎没有讨论如何在其他地方 link 的模态 内部 添加内容。理想情况下,此模式将有一条消息,但也有一个 links 到 jira 的按钮。我在想这样的事情:

import dash_html_components as html
from dash.dependencies import Input, Output, State

modal = html.Div(
   [
       dbc.Button("Open", id="open-centered"),
       dbc.Modal(
           [
               dbc.ModalHeader("Request"),
               dbc.ModalBody("Click the link below to be directed to your request"),
               dbc.ModalFooter(
                   dbc.Button(
                       "Close", id="close-centered", className="ml-auto"
                   )
                   dbc.Button(
                       "External Link", id="link-centered", className="ml-auto"
                   )
               ),
           ],
           id="modal-centered",
           centered=True,
       ),
   ]
)


@app.callback(
   Output("modal-centered", "is_open"),
   [Input("open-centered", "n_clicks"), Input("close-centered", "n_clicks")],
   [State("modal-centered", "is_open")],
)
def toggle_modal(n1, n2, is_open):
   if n1 or n2:
       return not is_open
   return is_open

外部 Link 按钮将在您的浏览器中打开一个新选项卡并导航到另一个网站,但我不确定。非常感谢任何帮助和建议,谢谢!

This is the page you need 来自文档。只需将 href 属性 添加到您的按钮即可。所以你会有这样的东西:

dbc.Button(
    "External Link",
    id="link-centered", 
    className="ml-auto",
    href='https://en.wikipedia.org/wiki/Main_Page'
)