simonraj commited on
Commit
e8fae22
·
verified ·
1 Parent(s): 9f654db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -18
app.py CHANGED
@@ -1,26 +1,14 @@
1
  import gradio as gr
2
 
3
- # Function to update the student numbers dropdown based on the selected class
4
- def update_dropdown(class_prefix):
5
- # Check if a class prefix is selected
6
- if class_prefix:
7
- # Generate student numbers for the selected class
8
- student_numbers = [f"{class_prefix}{str(i).zfill(2)}" for i in range(1, 41)]
9
- return student_numbers
10
- else:
11
- # Return an empty list if no class prefix is selected
12
- return []
13
 
14
- # List of class options for the dropdown
15
- class_options = ["5H", "5E", "5RS"]
16
-
17
- # Create the Gradio interface with two dropdowns
18
  with gr.Blocks() as demo:
19
- with gr.Row():
20
- class_dropdown = gr.Dropdown(label="Class", choices=class_options)
21
- student_dropdown = gr.Dropdown(label="Student", choices=[])
22
 
23
- # Update student dropdown when class dropdown changes
24
  class_dropdown.change(fn=update_dropdown, inputs=class_dropdown, outputs=student_dropdown)
25
 
26
  # Run the app
 
1
  import gradio as gr
2
 
3
+ # ... (rest of your code)
 
 
 
 
 
 
 
 
 
4
 
5
+ # Create the Gradio interface
 
 
 
6
  with gr.Blocks() as demo:
7
+ class_dropdown = gr.Dropdown(label="Class", choices=class_options)
8
+ # Initialize the second dropdown with a callable for dynamic updates
9
+ student_dropdown = gr.Dropdown(label="Student", choices=lambda: update_dropdown(class_options[0]))
10
 
11
+ # Bind the update function to the change event of the class dropdown
12
  class_dropdown.change(fn=update_dropdown, inputs=class_dropdown, outputs=student_dropdown)
13
 
14
  # Run the app