hlydecker commited on
Commit
0f94921
·
verified ·
1 Parent(s): 65a5e9b

patch: fix to participant mgmt again

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -13,15 +13,17 @@ def add_participant(participant):
13
 
14
  clean_name = participant.strip()
15
  participants_set.add(clean_name)
16
- participants_list = list(participants_set)
17
- return participants_list, participants_list, participants_list
 
18
 
19
  def remove_participant(participant):
20
  global participants_set
21
  if participant in participants_set:
22
  participants_set.remove(participant)
23
- participants_list = list(participants_set)
24
- return participants_list, participants_list, participants_list
 
25
 
26
  # Add expenses
27
  def add_expense(description, amount, payer, participants_list):
@@ -128,15 +130,16 @@ with gr.Blocks(theme='soft') as app:
128
  # Participant Management
129
  with gr.Row():
130
  with gr.Column():
131
- participant_input = gr.Textbox(label="Participant Name")
132
  with gr.Row():
133
  add_participant_btn = gr.Button("Add Participant")
134
  remove_participant_btn = gr.Button("Remove Participant")
135
-
136
- participants_list = gr.Dropdown(
137
  label="Current Participants",
138
- multiselect=True,
139
- interactive=True
 
140
  )
141
 
142
  # Expense Adding
@@ -169,13 +172,13 @@ with gr.Blocks(theme='soft') as app:
169
  add_participant_btn.click(
170
  add_participant,
171
  inputs=participant_input,
172
- outputs=[participants_list, payer, participants]
173
  )
174
-
175
  remove_participant_btn.click(
176
  remove_participant,
177
  inputs=participant_input,
178
- outputs=[participants_list, payer, participants]
179
  )
180
 
181
  add_btn.click(
 
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):
 
130
  # Participant Management
131
  with gr.Row():
132
  with gr.Column():
133
+ participant_input = gr.Textbox(label="Participant Name", placeholder="Enter a participant name")
134
  with gr.Row():
135
  add_participant_btn = gr.Button("Add Participant")
136
  remove_participant_btn = gr.Button("Remove Participant")
137
+
138
+ participants_display = gr.Textbox(
139
  label="Current Participants",
140
+ lines=10,
141
+ interactive=False,
142
+ placeholder="Participants will appear here..."
143
  )
144
 
145
  # Expense Adding
 
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(