modernai commited on
Commit
2788bc8
·
verified ·
1 Parent(s): b19d417

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -22,10 +22,10 @@ def create_portfolio_graph(amount):
22
 
23
  return chart
24
 
25
- def on_submit(button):
26
- amount = button.inputs[0]
27
- plot = button.outputs[0]
28
- plot.update(create_portfolio_graph(amount))
29
 
30
  with gr.Blocks() as demo:
31
  title = gr.Markdown(
@@ -34,8 +34,9 @@ with gr.Blocks() as demo:
34
  """
35
  )
36
  total_funds_input = gr.Number(value=0)
 
37
  plot = gr.Plot(label="Portfolio Composition Chart")
38
- button = gr.Button("Submit", onclick=on_submit, args=[total_funds_input])
39
  demo.load(create_portfolio_graph, inputs=[total_funds_input, button], outputs=[title, plot])
40
 
41
  if __name__ == "__main__":
@@ -62,5 +63,6 @@ if __name__ == "__main__":
62
 
63
 
64
 
 
65
 
66
 
 
22
 
23
  return chart
24
 
25
+ def on_submit():
26
+ # Callback function to handle button click
27
+ amount = total_funds_input.value
28
+ plot.change(create_portfolio_graph, inputs=[total_funds_input], outputs=[plot])
29
 
30
  with gr.Blocks() as demo:
31
  title = gr.Markdown(
 
34
  """
35
  )
36
  total_funds_input = gr.Number(value=0)
37
+ button = gr.Button("Submit", click=on_submit)
38
  plot = gr.Plot(label="Portfolio Composition Chart")
39
+
40
  demo.load(create_portfolio_graph, inputs=[total_funds_input, button], outputs=[title, plot])
41
 
42
  if __name__ == "__main__":
 
63
 
64
 
65
 
66
+
67
 
68