ankban commited on
Commit
e0ba2d0
Β·
verified Β·
1 Parent(s): d3d2ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -36
app.py CHANGED
@@ -3,42 +3,55 @@ from spoken_module import spoken_dashboard
3
  from written_module import written_dashboard
4
  from file_module import file_dashboard
5
 
6
- with gr.Blocks(css="light_mode_chatter_owl.css") as app:
7
- study_type = gr.State("spoken")
8
-
9
- with gr.Row():
10
- with gr.Column(scale=1, min_width=200):
11
- gr.Markdown("### πŸ“š Study Modes")
12
- btn_spoken = gr.Button("πŸ—£ Spoken Communication")
13
- btn_written = gr.Button("✍️ Written Communication")
14
- btn_file = gr.Button("πŸ“„ File-based Learning")
15
-
16
- with gr.Column(scale=4):
17
- output_panel = gr.Column()
18
-
19
- # Dynamic sections
20
- spoken_panel = spoken_dashboard()
21
- written_panel = written_dashboard()
22
- file_panel = gr.Column(visible=False)
23
- with file_panel:
24
- file_dashboard()
25
-
26
- spoken_panel.visible = True
27
- written_panel.visible = False
28
- file_panel.visible = False
29
-
30
- def switch_mode(mode):
31
- return (
32
- gr.update(visible=(mode == "spoken")),
33
- gr.update(visible=(mode == "written")),
34
- gr.update(visible=(mode == "file")),
35
- mode
36
- )
37
-
38
- btn_spoken.click(fn=lambda: switch_mode("spoken"), inputs=[], outputs=[spoken_panel, written_panel, file_panel, study_type])
39
- btn_written.click(fn=lambda: switch_mode("written"), inputs=[], outputs=[spoken_panel, written_panel, file_panel, study_type])
40
- btn_file.click(fn=lambda: switch_mode("file"), inputs=[], outputs=[spoken_panel, written_panel, file_panel, study_type])
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
 
43
  if __name__ == "__main__":
44
- app.launch(server_name="0.0.0.0", server_port=7860)
 
3
  from written_module import written_dashboard
4
  from file_module import file_dashboard
5
 
6
+
7
+ def main_app():
8
+ with gr.Blocks(css="light_mode_chatter_owl.css") as app:
9
+ current_mode = gr.State("spoken")
10
+
11
+ with gr.Row():
12
+ # === LEFT SIDEBAR ===
13
+ with gr.Column(scale=1, min_width=220):
14
+ gr.Markdown("### πŸŽ“ Educare")
15
+ gr.Markdown("---")
16
+
17
+ with gr.Accordion("🧭 Learning Modes", open=True):
18
+ btn_spoken = gr.Button("πŸ—£ Spoken Communication")
19
+ btn_written = gr.Button("✍️ Written Communication")
20
+ btn_file = gr.Button("πŸ“„ File-Based Learning")
21
+
22
+ gr.Markdown("---")
23
+ gr.Markdown("**Ankush Bansal**
24
+ ankban@wharton.upenn.edu")
25
+
26
+ # === MAIN CONTENT PANEL ===
27
+ with gr.Column(scale=4):
28
+ spoken_panel = gr.Column(visible=True)
29
+ written_panel = gr.Column(visible=False)
30
+ file_panel = gr.Column(visible=False)
31
+
32
+ with spoken_panel:
33
+ spoken_dashboard()
34
+
35
+ with written_panel:
36
+ written_dashboard()
37
+
38
+ with file_panel:
39
+ file_dashboard()
40
+
41
+ def switch_mode(mode):
42
+ return (
43
+ gr.update(visible=(mode == "spoken")),
44
+ gr.update(visible=(mode == "written")),
45
+ gr.update(visible=(mode == "file")),
46
+ mode
47
+ )
48
+
49
+ btn_spoken.click(lambda: switch_mode("spoken"), outputs=[spoken_panel, written_panel, file_panel, current_mode])
50
+ btn_written.click(lambda: switch_mode("written"), outputs=[spoken_panel, written_panel, file_panel, current_mode])
51
+ btn_file.click(lambda: switch_mode("file"), outputs=[spoken_panel, written_panel, file_panel, current_mode])
52
+
53
+ return app
54
 
55
 
56
  if __name__ == "__main__":
57
+ main_app().launch(server_name="0.0.0.0", server_port=7860)