File size: 827 Bytes
c943374 7962920 b84370e 7962920 b84370e 7962920 c943374 e8fae22 c943374 b84370e c943374 b84370e c943374 7962920 c943374 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
def update_dropdown(class_prefix):
# Generate a list of student numbers for the class
if class_prefix is not None:
return [f"{class_prefix}{str(i).zfill(2)}" for i in range(1, 41)]
return []
# Define class options for the first dropdown
class_options = ["5H", "5E", "5RS"]
# Create the Gradio interface
with gr.Blocks() as demo:
class_dropdown = gr.Dropdown(label="Class", choices=class_options, value=class_options[0])
# Initialize the second dropdown with the values from the first class as default
student_dropdown = gr.Dropdown(label="Student", choices=update_dropdown(class_options[0]))
# Bind the update function to the class dropdown
class_dropdown.change(fn=update_dropdown, inputs=class_dropdown, outputs=student_dropdown)
# Launch the app
demo.launch() |