|
import gradio as gr |
|
|
|
def update_dropdown(class_prefix): |
|
|
|
if class_prefix is not None: |
|
return [f"{class_prefix}{str(i).zfill(2)}" for i in range(1, 41)] |
|
return [] |
|
|
|
|
|
class_options = ["5H", "5E", "5RS"] |
|
|
|
|
|
with gr.Blocks() as demo: |
|
class_dropdown = gr.Dropdown(label="Class", choices=class_options, value=class_options[0]) |
|
|
|
student_dropdown = gr.Dropdown(label="Student", choices=update_dropdown(class_options[0])) |
|
|
|
|
|
class_dropdown.change(fn=update_dropdown, inputs=class_dropdown, outputs=student_dropdown) |
|
|
|
|
|
demo.launch() |