Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -16,11 +16,11 @@ def add_participant(participant):
|
|
16 |
participants_list = sorted(list(participants_set)) # Sort for consistent display
|
17 |
participants_text = "\n".join(participants_list)
|
18 |
|
19 |
-
# Return updated participant list
|
20 |
return (
|
21 |
participants_text,
|
22 |
-
gr.Dropdown
|
23 |
-
gr.Dropdown
|
24 |
)
|
25 |
|
26 |
def remove_participant(participant):
|
@@ -28,14 +28,14 @@ def remove_participant(participant):
|
|
28 |
participant = participant.strip()
|
29 |
if participant in participants_set:
|
30 |
participants_set.remove(participant)
|
31 |
-
participants_list = sorted(list(participants_set))
|
32 |
participants_text = "\n".join(participants_list)
|
33 |
|
34 |
-
# Return updated participant list
|
35 |
return (
|
36 |
participants_text,
|
37 |
-
gr.Dropdown
|
38 |
-
gr.Dropdown
|
39 |
)
|
40 |
|
41 |
# Add expenses
|
@@ -128,7 +128,7 @@ def optimize_balances():
|
|
128 |
|
129 |
return transactions if transactions else ["No transactions needed"]
|
130 |
|
131 |
-
return simplify_debts(balances)
|
132 |
|
133 |
# Reset App
|
134 |
def reset():
|
@@ -139,10 +139,10 @@ def reset():
|
|
139 |
participants_text = ""
|
140 |
return (
|
141 |
pd.DataFrame(expenses),
|
142 |
-
|
143 |
participants_text,
|
144 |
-
gr.Dropdown
|
145 |
-
gr.Dropdown
|
146 |
)
|
147 |
|
148 |
# Gradio Interface
|
@@ -217,6 +217,7 @@ with gr.Blocks(theme='soft') as app:
|
|
217 |
reset_btn = gr.Button("Reset")
|
218 |
|
219 |
optimize_btn.click(optimize_balances, inputs=[], outputs=result)
|
|
|
220 |
reset_btn.click(
|
221 |
reset,
|
222 |
inputs=[],
|
|
|
16 |
participants_list = sorted(list(participants_set)) # Sort for consistent display
|
17 |
participants_text = "\n".join(participants_list)
|
18 |
|
19 |
+
# Return updated participant list and new Dropdown instances
|
20 |
return (
|
21 |
participants_text,
|
22 |
+
gr.Dropdown(choices=participants_list, label="Payer", interactive=True),
|
23 |
+
gr.Dropdown(choices=participants_list, label="Participants", multiselect=True, interactive=True)
|
24 |
)
|
25 |
|
26 |
def remove_participant(participant):
|
|
|
28 |
participant = participant.strip()
|
29 |
if participant in participants_set:
|
30 |
participants_set.remove(participant)
|
31 |
+
participants_list = sorted(list(participants_set)) # Sort for consistent display
|
32 |
participants_text = "\n".join(participants_list)
|
33 |
|
34 |
+
# Return updated participant list and new Dropdown instances
|
35 |
return (
|
36 |
participants_text,
|
37 |
+
gr.Dropdown(choices=participants_list, label="Payer", interactive=True),
|
38 |
+
gr.Dropdown(choices=participants_list, label="Participants", multiselect=True, interactive=True)
|
39 |
)
|
40 |
|
41 |
# Add expenses
|
|
|
128 |
|
129 |
return transactions if transactions else ["No transactions needed"]
|
130 |
|
131 |
+
return "\n".join(simplify_debts(balances))
|
132 |
|
133 |
# Reset App
|
134 |
def reset():
|
|
|
139 |
participants_text = ""
|
140 |
return (
|
141 |
pd.DataFrame(expenses),
|
142 |
+
"",
|
143 |
participants_text,
|
144 |
+
gr.Dropdown(choices=participants_list, label="Payer", interactive=True),
|
145 |
+
gr.Dropdown(choices=participants_list, label="Participants", multiselect=True, interactive=True)
|
146 |
)
|
147 |
|
148 |
# Gradio Interface
|
|
|
217 |
reset_btn = gr.Button("Reset")
|
218 |
|
219 |
optimize_btn.click(optimize_balances, inputs=[], outputs=result)
|
220 |
+
|
221 |
reset_btn.click(
|
222 |
reset,
|
223 |
inputs=[],
|