Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -46,6 +46,15 @@ with gr.Blocks() as nps:
|
|
46 |
return category_list
|
47 |
|
48 |
category_boxes = gr.State([]) # Store category input boxes as state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
category_input = gr.Textbox(label="New Category", placeholder="Enter category name")
|
50 |
def remove_category(category, category_list):
|
51 |
category_list.remove(category) # Remove selected category
|
|
|
46 |
return category_list
|
47 |
|
48 |
category_boxes = gr.State([]) # Store category input boxes as state
|
49 |
+
|
50 |
+
def display_categories(categories):
|
51 |
+
category_components = []
|
52 |
+
for i, cat in enumerate(categories):
|
53 |
+
with gr.Row():
|
54 |
+
gr.Markdown(f"- {cat}")
|
55 |
+
remove_btn = gr.Button("X", elem_id=f"remove_{i}", interactive=True)
|
56 |
+
remove_btn.click(fn=lambda x=cat: remove_category(x, categories), inputs=[], outputs=category_boxes)
|
57 |
+
return category_components
|
58 |
category_input = gr.Textbox(label="New Category", placeholder="Enter category name")
|
59 |
def remove_category(category, category_list):
|
60 |
category_list.remove(category) # Remove selected category
|