Update app.py
Browse files
app.py
CHANGED
|
@@ -10,24 +10,28 @@ def main_app():
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
gr.Markdown("---")
|
| 23 |
-
gr.
|
| 24 |
-
ankban@wharton.upenn.edu""")
|
| 25 |
|
| 26 |
# === MAIN CONTENT PANEL ===
|
| 27 |
with gr.Column(scale=4):
|
| 28 |
-
spoken_panel = gr.
|
| 29 |
-
written_panel = gr.
|
| 30 |
-
file_panel = gr.
|
|
|
|
| 31 |
|
| 32 |
with spoken_panel:
|
| 33 |
spoken_dashboard()
|
|
@@ -38,20 +42,25 @@ ankban@wharton.upenn.edu""")
|
|
| 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 |
-
|
|
|
|
| 52 |
|
| 53 |
return app
|
| 54 |
|
| 55 |
|
| 56 |
if __name__ == "__main__":
|
| 57 |
-
main_app().launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 10 |
|
| 11 |
with gr.Row():
|
| 12 |
# === LEFT SIDEBAR ===
|
| 13 |
+
with gr.Column(scale=1, min_width=220, elem_id="sidebar"):
|
| 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 |
+
|
| 21 |
+
with gr.Accordion("π File-Based Learning", open=False):
|
| 22 |
+
btn_file_study = gr.Button("π Study Guides")
|
| 23 |
+
btn_file_view = gr.Button("π Files")
|
| 24 |
|
| 25 |
gr.Markdown("---")
|
| 26 |
+
with gr.Row():
|
| 27 |
+
gr.Markdown("""<div style='position: absolute; bottom: 1rem;'>**Ankush Bansal**<br>ankban@wharton.upenn.edu</div>""", elem_id="sidebar-user")
|
| 28 |
|
| 29 |
# === MAIN CONTENT PANEL ===
|
| 30 |
with gr.Column(scale=4):
|
| 31 |
+
spoken_panel = gr.Box(visible=True)
|
| 32 |
+
written_panel = gr.Box(visible=False)
|
| 33 |
+
file_panel = gr.Box(visible=False)
|
| 34 |
+
file_study_panel = gr.Box(visible=False)
|
| 35 |
|
| 36 |
with spoken_panel:
|
| 37 |
spoken_dashboard()
|
|
|
|
| 42 |
with file_panel:
|
| 43 |
file_dashboard()
|
| 44 |
|
| 45 |
+
with file_study_panel:
|
| 46 |
+
file_dashboard() # temporary reuse; can split later
|
| 47 |
+
|
| 48 |
def switch_mode(mode):
|
| 49 |
return (
|
| 50 |
gr.update(visible=(mode == "spoken")),
|
| 51 |
gr.update(visible=(mode == "written")),
|
| 52 |
gr.update(visible=(mode == "file")),
|
| 53 |
+
gr.update(visible=(mode == "study")),
|
| 54 |
mode
|
| 55 |
)
|
| 56 |
|
| 57 |
+
btn_spoken.click(lambda: switch_mode("spoken"), outputs=[spoken_panel, written_panel, file_panel, file_study_panel, current_mode])
|
| 58 |
+
btn_written.click(lambda: switch_mode("written"), outputs=[spoken_panel, written_panel, file_panel, file_study_panel, current_mode])
|
| 59 |
+
btn_file_view.click(lambda: switch_mode("file"), outputs=[spoken_panel, written_panel, file_panel, file_study_panel, current_mode])
|
| 60 |
+
btn_file_study.click(lambda: switch_mode("study"), outputs=[spoken_panel, written_panel, file_panel, file_study_panel, current_mode])
|
| 61 |
|
| 62 |
return app
|
| 63 |
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
+
main_app().launch(server_name="0.0.0.0", server_port=7860)
|