Hi I am trying to create an interactive dash table where I can list an array of xyz positions and the motors should move to those positions row-by-row after I press an execute button (see image)
For now, I want to see if I can mimic this by printing out the rows one by one after I press the execute button. This is my html input:
params = ['x', 'y', 'z']
...
html.Div(
[
dash_table.DataTable(
id='table',
columns=(
[{'id': 'Model', 'name': 'Model'}] +
[{'id': p, 'name': p} for p in params]
),
data=[
dict(Model=i, **{param: 0 for param in params})
for i in range(1, 3)
],
style_cell_conditional=[
{'if': {'column_id': 'Model'},
'width': '100px'},
{'if': {'column_id': 'x'},
'width': '100px'},
{'if': {'column_id': 'y'},
'width': '100px'},
{'if': {'column_id': 'z'},
'width': '100px'},
],
n_fixed_rows=1,
editable=True,
),
], className="six columns"
),
html.Button(
'Execute',
id="run",
className="one columns",
n_clicks=0,
style={
# "float": "right",
"display": "flex",
"justify-content": "center",
"align-items": "center",
"marginLeft": "2%",
"marginTop": "0%",
},
),
# Placeholder Divs
html.Div(
[
html.Div(id="table-output"),
html.Div(id="run-output"),
],
),
and this is my app callback:
@app.callback(
Output("run-output", "children"),
[Input("run", "n_clicks"),
Input("table", "data"),
Input("table", "columns")]
)
def run_spots(n_clicks, rows, cols):
df = pd.DataFrame(rows, cols=[c['name'] for c in cols])
if n_clicks >= 1:
return [col['name'], df[col['id']]] for col in cols]
As you can see I am not too sure how to exactly do this part. Can anyone please advise?
Cheers, H