import gradio as gr # This function is called whenever the class dropdown changes. def update_student_dropdown(class_selection): # Generate the list of student numbers for the selected class student_numbers = [f"{class_selection}{str(i).zfill(2)}" for i in range(1, 41)] return student_numbers # Define your class options for the dropdown class_options = ["5H", "5E", "5RS"] with gr.Blocks() as demo: class_dropdown = gr.Dropdown(label="Class", choices=class_options, value="5H") student_dropdown = gr.Dropdown(label="Student", choices=update_student_dropdown("5H")) # Use the change event to update the student dropdown when the class changes class_dropdown.change(fn=update_student_dropdown, inputs=class_dropdown, outputs=student_dropdown) demo.launch()