我在运行新的 Dash 版本 (2.11) 时遇到一些问题。 我习惯在回调中使用一些打印语句作为调试功能(打印值、值类型等),并且一切正常,每次单击回调时,打印语句都会在块之后打印在 jupyter_lab 中。
这是代码的最小工作示例,现在打印语句不起作用。 有没有人可以帮我解决这个问题?
from dash import Dash, html
from dash import Dash, dcc, html, Input, Output, State, dash_table, callback_context
import dash_bootstrap_components as dbc
import jupyterlab_dash
from jupyter_dash import JupyterDash
app = Dash(external_stylesheets=[dbc.themes.SLATE])#[dbc.themes.SLATE])
#run the server locally without the aid of the internet connection
# Serve files locally
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app = JupyterDash(external_stylesheets=[dbc.themes.SLATE] )#[dbc.themes.SLATE]) SLATE #2
#run the server locally without the aid of the internet connection
# Serve files locally
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.layout = dbc.Container(
[html.Button('click-me', id='button', n_clicks=0),
html.H1('click-me', id = "text")
]
)
@app.callback(
[
Output("text", "children")
]
,
[
Input("button", "n_clicks"),
]
)
def button(n_clicks):
print("button is pressed")
return ["button was pressed {} times ".format(n_clicks)]
if __name__ == '__main__':
app.run_server(debug=True,port = 8057, jupyter_mode="external")