File size: 793 Bytes
c943374
 
c2a9970
 
 
 
 
7962920
c2a9970
 
c943374
 
c2a9970
 
 
 
 
c943374
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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()