File size: 959 Bytes
c943374 9f654db c943374 9f654db c943374 9f654db c943374 9f654db c943374 9f654db c943374 9f654db c943374 9f654db c943374 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
import gradio as gr
# Function to update the student numbers dropdown based on the selected class
def update_dropdown(class_prefix):
# Check if a class prefix is selected
if class_prefix:
# Generate student numbers for the selected class
student_numbers = [f"{class_prefix}{str(i).zfill(2)}" for i in range(1, 41)]
return student_numbers
else:
# Return an empty list if no class prefix is selected
return []
# List of class options for the dropdown
class_options = ["5H", "5E", "5RS"]
# Create the Gradio interface with two dropdowns
with gr.Blocks() as demo:
with gr.Row():
class_dropdown = gr.Dropdown(label="Class", choices=class_options)
student_dropdown = gr.Dropdown(label="Student", choices=[])
# Update student dropdown when class dropdown changes
class_dropdown.change(fn=update_dropdown, inputs=class_dropdown, outputs=student_dropdown)
# Run the app
demo.launch() |