Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -70,11 +70,39 @@ def is_month_end():
|
|
70 |
today = datetime.now()
|
71 |
return (today.day == (pd.Period(today.strftime("%Y-%m")).days_in_month))
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
with gr.Blocks() as app:
|
74 |
gr.Markdown("# Attendance Tracker")
|
75 |
|
76 |
with gr.Row():
|
77 |
-
name = gr.Textbox(label="Name")
|
|
|
78 |
day = gr.Textbox(label="Day")
|
79 |
date = gr.Textbox(label="Date (YYYY-MM-DD)")
|
80 |
status = gr.Radio(["Present", "Absent"], label="Status")
|
|
|
70 |
today = datetime.now()
|
71 |
return (today.day == (pd.Period(today.strftime("%Y-%m")).days_in_month))
|
72 |
|
73 |
+
# Function to extract data from Excel
|
74 |
+
def get_dropdown_options(file_path, column_name):
|
75 |
+
# Read the Excel file
|
76 |
+
df = pd.read_excel(file_path)
|
77 |
+
# Extract the unique values from the specified column
|
78 |
+
options = df["Name"].dropna().unique().tolist()
|
79 |
+
return options
|
80 |
+
|
81 |
+
# Define the Gradio interface
|
82 |
+
def dropdown_demo():
|
83 |
+
# File path and column to read
|
84 |
+
file_path = "participants_form.xlsx" # Replace with your Excel file path
|
85 |
+
column_name = "your_column" # Replace with your column name in the Excel file
|
86 |
+
|
87 |
+
# Populate dropdown options
|
88 |
+
options = get_dropdown_options(file_path, column_name)
|
89 |
+
|
90 |
+
# Define a Gradio app
|
91 |
+
with gr.Blocks() as demo:
|
92 |
+
dropdown = gr.Dropdown(choices=options, label="Select an Option")
|
93 |
+
output = gr.Textbox(label="You Selected")
|
94 |
+
|
95 |
+
def show_selection(choice):
|
96 |
+
return f"You selected: {choice}"
|
97 |
+
|
98 |
+
dropdown.change(show_selection, inputs=[dropdown], outputs=[output])
|
99 |
+
|
100 |
with gr.Blocks() as app:
|
101 |
gr.Markdown("# Attendance Tracker")
|
102 |
|
103 |
with gr.Row():
|
104 |
+
# name = gr.Textbox(label="Name")
|
105 |
+
name = dropdown_demo()
|
106 |
day = gr.Textbox(label="Day")
|
107 |
date = gr.Textbox(label="Date (YYYY-MM-DD)")
|
108 |
status = gr.Radio(["Present", "Absent"], label="Status")
|