fork download
  1. import dash
  2. import dash_cytoscape as cyto
  3. import dash_html_components as html
  4. import dash_daq as daq
  5. from dash.dependencies import Input, Output, State
  6.  
  7. app = dash.Dash(__name__)
  8.  
  9. app.layout = html.Div([
  10.  
  11. html.Div([
  12. html.Button('Button', id='btn-node', n_clicks_timestamp=0)
  13. ]),
  14.  
  15. cyto.Cytoscape(
  16. id='cytoscape-elements-basic',
  17. layout={'name': 'preset'},
  18. style={'width': '100%', 'height': '400px'},
  19. elements=[]
  20. )
  21. ])
  22.  
  23. @app.callback(
  24. Output('cytoscape-elements-basic', 'elements'),
  25. Input('btn-node', 'n_clicks_timestamp'),
  26. State('cytoscape-elements-basic', 'elements'))
  27. def update_elements(btn, elements):
  28.  
  29. some_list = [1,2,3]
  30.  
  31. if int(btn):
  32.  
  33. return [{'data': {'id': x}} for x in some_list]
  34.  
  35. return elements
  36.  
  37. if __name__ == '__main__':
  38. app.run_server(debug=True)
Runtime error #stdin #stdout #stderr 0.16s 22996KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ModuleNotFoundError: No module named 'dash'