Spaces:
Running
Running
Yuxuan-Zhang-Dexter
commited on
Commit
·
7015e70
1
Parent(s):
fe89fc2
update search bar
Browse files
app.py
CHANGED
|
@@ -127,6 +127,7 @@ def update_df_with_height(df):
|
|
| 127 |
show_row_numbers=True,
|
| 128 |
show_fullscreen_button=True,
|
| 129 |
line_breaks=True,
|
|
|
|
| 130 |
max_height=700)
|
| 131 |
|
| 132 |
def update_leaderboard(mario_overall, mario_details,
|
|
@@ -701,17 +702,6 @@ def build_app():
|
|
| 701 |
with gr.Row():
|
| 702 |
gr.Markdown("### 📋 Detailed Results")
|
| 703 |
|
| 704 |
-
# Add leaderboard search box in its own row
|
| 705 |
-
with gr.Row():
|
| 706 |
-
with gr.Column(scale=8):
|
| 707 |
-
search_box = gr.Textbox(
|
| 708 |
-
label="🔍 Search by Player or Organization",
|
| 709 |
-
placeholder="Type to filter the table...",
|
| 710 |
-
show_label=True
|
| 711 |
-
)
|
| 712 |
-
with gr.Column(scale=1):
|
| 713 |
-
search_clear_btn = gr.Button("Clear", variant="secondary")
|
| 714 |
-
|
| 715 |
# Get initial leaderboard dataframe
|
| 716 |
initial_df = get_combined_leaderboard(rank_data, {
|
| 717 |
"Super Mario Bros": True,
|
|
@@ -736,45 +726,14 @@ def build_app():
|
|
| 736 |
show_row_numbers=True,
|
| 737 |
show_fullscreen_button=True,
|
| 738 |
line_breaks=True,
|
| 739 |
-
max_height=700
|
|
|
|
| 740 |
)
|
| 741 |
|
| 742 |
# Add the score note below the table
|
| 743 |
with gr.Row():
|
| 744 |
score_note = add_score_note()
|
| 745 |
|
| 746 |
-
# Add search functionality
|
| 747 |
-
def filter_table(search_term, current_df):
|
| 748 |
-
# Create a fresh copy of the DataFrame to avoid modifying the original
|
| 749 |
-
filtered_df = current_df.copy()
|
| 750 |
-
|
| 751 |
-
# Only apply search if a term is provided
|
| 752 |
-
if search_term:
|
| 753 |
-
# Filter the DataFrame by Player or Organization
|
| 754 |
-
filtered_df = filtered_df[
|
| 755 |
-
filtered_df["Player"].str.contains(search_term, case=False) |
|
| 756 |
-
filtered_df["Organization"].str.contains(search_term, case=False)
|
| 757 |
-
]
|
| 758 |
-
|
| 759 |
-
return filtered_df
|
| 760 |
-
|
| 761 |
-
# Connect search box to the table
|
| 762 |
-
search_box.change(
|
| 763 |
-
filter_table,
|
| 764 |
-
inputs=[search_box, leaderboard_df],
|
| 765 |
-
outputs=[leaderboard_df]
|
| 766 |
-
)
|
| 767 |
-
|
| 768 |
-
# Clear search button functionality
|
| 769 |
-
def clear_search():
|
| 770 |
-
return "", initial_display_df
|
| 771 |
-
|
| 772 |
-
search_clear_btn.click(
|
| 773 |
-
clear_search,
|
| 774 |
-
inputs=[],
|
| 775 |
-
outputs=[search_box, leaderboard_df]
|
| 776 |
-
)
|
| 777 |
-
|
| 778 |
# List of all checkboxes
|
| 779 |
checkbox_list = [
|
| 780 |
mario_overall, mario_details,
|
|
|
|
| 127 |
show_row_numbers=True,
|
| 128 |
show_fullscreen_button=True,
|
| 129 |
line_breaks=True,
|
| 130 |
+
show_search="search",
|
| 131 |
max_height=700)
|
| 132 |
|
| 133 |
def update_leaderboard(mario_overall, mario_details,
|
|
|
|
| 702 |
with gr.Row():
|
| 703 |
gr.Markdown("### 📋 Detailed Results")
|
| 704 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 705 |
# Get initial leaderboard dataframe
|
| 706 |
initial_df = get_combined_leaderboard(rank_data, {
|
| 707 |
"Super Mario Bros": True,
|
|
|
|
| 726 |
show_row_numbers=True,
|
| 727 |
show_fullscreen_button=True,
|
| 728 |
line_breaks=True,
|
| 729 |
+
max_height=700,
|
| 730 |
+
show_search="search"
|
| 731 |
)
|
| 732 |
|
| 733 |
# Add the score note below the table
|
| 734 |
with gr.Row():
|
| 735 |
score_note = add_score_note()
|
| 736 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 737 |
# List of all checkboxes
|
| 738 |
checkbox_list = [
|
| 739 |
mario_overall, mario_details,
|