hlydecker commited on
Commit
280b1e8
·
verified ·
1 Parent(s): 0f94921

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -13,17 +13,21 @@ def add_participant(participant):
13
 
14
  clean_name = participant.strip()
15
  participants_set.add(clean_name)
16
- participants_list = sorted(list(participants_set)) # Ensure alphabetical order
17
  participants_text = "\n".join(participants_list)
18
- return participants_text
 
 
19
 
20
  def remove_participant(participant):
21
  global participants_set
22
  if participant in participants_set:
23
  participants_set.remove(participant)
24
- participants_list = sorted(list(participants_set)) # Ensure alphabetical order
25
  participants_text = "\n".join(participants_list)
26
- return participants_text
 
 
27
 
28
  # Add expenses
29
  def add_expense(description, amount, payer, participants_list):
@@ -150,12 +154,14 @@ with gr.Blocks(theme='soft') as app:
150
 
151
  payer = gr.Dropdown(
152
  label="Payer",
 
153
  interactive=True
154
  )
155
 
156
  participants = gr.Dropdown(
157
  label="Participants",
158
- multiselect=True,
 
159
  interactive=True
160
  )
161
 
@@ -172,13 +178,13 @@ with gr.Blocks(theme='soft') as app:
172
  add_participant_btn.click(
173
  add_participant,
174
  inputs=participant_input,
175
- outputs=participants_display
176
  )
177
 
178
  remove_participant_btn.click(
179
  remove_participant,
180
  inputs=participant_input,
181
- outputs=participants_display
182
  )
183
 
184
  add_btn.click(
 
13
 
14
  clean_name = participant.strip()
15
  participants_set.add(clean_name)
16
+ participants_list = sorted(list(participants_set)) # Sort for consistent display
17
  participants_text = "\n".join(participants_list)
18
+
19
+ # Return updated participant list for dropdowns
20
+ return participants_text, participants_list, participants_list
21
 
22
  def remove_participant(participant):
23
  global participants_set
24
  if participant in participants_set:
25
  participants_set.remove(participant)
26
+ participants_list = sorted(list(participants_set)) # Sort for consistent display
27
  participants_text = "\n".join(participants_list)
28
+
29
+ # Return updated participant list for dropdowns
30
+ return participants_text, participants_list, participants_list
31
 
32
  # Add expenses
33
  def add_expense(description, amount, payer, participants_list):
 
154
 
155
  payer = gr.Dropdown(
156
  label="Payer",
157
+ choices=[],
158
  interactive=True
159
  )
160
 
161
  participants = gr.Dropdown(
162
  label="Participants",
163
+ multiselect=True,
164
+ choices=[],
165
  interactive=True
166
  )
167
 
 
178
  add_participant_btn.click(
179
  add_participant,
180
  inputs=participant_input,
181
+ outputs=[participants_display, payer, participants]
182
  )
183
 
184
  remove_participant_btn.click(
185
  remove_participant,
186
  inputs=participant_input,
187
+ outputs=[participants_display, payer, participants]
188
  )
189
 
190
  add_btn.click(