我在 plotly/dash 中有一个基本的数据表。我的目标是在按下上传按钮后上传(或为了示例而打印...)。
问题是,我不知道如何将按钮的 n_clicks 属性恢复为零。所以发生的事情是,在我第一次点击按钮后,只要有变化(添加行或更改/添加数字),它就会连续打印,但我想要的是每当我点击按钮时它只打印一次。
这是代码:
import dash
from dash.dependencies import Input, Output, State
import dash_table
import dash_daq as daq
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
df = pd.read_csv('.../dummy_csv.csv')
app = dash.Dash(__name__)
app.layout = html.Div([
html.Div(id='my-div'),
dash_table.DataTable(
id='adding-rows-table',
style_data={
'whiteSpace': 'normal',
'height': 'auto'
},
style_table={
'maxHeight': '800px'
, 'overflowY': 'scroll'
},
columns=[
{'name': i, 'id': i} for i in df.columns
],
data=df.to_dict('records'),
editable=True,
row_deletable=True
),
html.Button('+ Row', id='editing-rows-button', n_clicks=0),
html.Button('Update', …Run Code Online (Sandbox Code Playgroud)