1mpreccable commited on
Commit
7457be4
·
verified ·
1 Parent(s): 30a4aaf

Rename run.py to app.py

Browse files
Files changed (1) hide show
  1. run.py → app.py +63 -21
run.py → app.py RENAMED
@@ -4,8 +4,19 @@ from interface_pages.about_page import about_page
4
  from interface_pages.yoga_position_from_stream import yoga_position_from_stream
5
  from interface_pages.yoga_position_from_video import yoga_position_from_video
6
 
 
 
 
 
 
 
 
 
 
 
7
  def interface():
8
  with gr.Blocks(css="static/styles.css") as demo:
 
9
  # Layout with a Row to hold buttons and content
10
  with gr.Row():
11
  with gr.Column(scale=1, elem_classes=["menu-column"]):
@@ -23,31 +34,62 @@ def interface():
23
  yoga_video_content = yoga_position_from_video()
24
 
25
  # Set initial visibility
26
- pages = [home_page_content, about_page_content, yoga_stream_content, yoga_video_content]
27
- for page in pages:
28
- page.visible = False
29
- home_page_content.visible = True # Show home page initially
30
 
31
  # Button click handlers
32
- def show_page(page_name):
33
- for page in pages:
34
- page.visible = False
35
- if page_name == "Home":
36
- home_page_content.visible = True
37
- elif page_name == "About us":
38
- about_page_content.visible = True
39
- elif page_name == "Yoga from stream":
40
- yoga_stream_content.visible = True
41
- elif page_name == "Yoga from video":
42
- yoga_video_content.visible = True
43
-
44
- home_button.click(lambda: show_page("Home"))
45
- about_button.click(lambda: show_page("About us"))
46
- yoga_stream_button.click(lambda: show_page("Yoga from stream"))
47
- yoga_video_button.click(lambda: show_page("Yoga from video"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  return demo
50
 
51
 
52
  if __name__ == "__main__":
53
- interface().launch()
 
4
  from interface_pages.yoga_position_from_stream import yoga_position_from_stream
5
  from interface_pages.yoga_position_from_video import yoga_position_from_video
6
 
7
+ def main(page):
8
+ if page == "Home":
9
+ return home_page()
10
+ elif page == "About us":
11
+ return about_page()
12
+ elif page == "Yoga from stream":
13
+ return yoga_position_from_stream()
14
+ elif page == "Yoga from video":
15
+ return yoga_position_from_video()
16
+
17
  def interface():
18
  with gr.Blocks(css="static/styles.css") as demo:
19
+
20
  # Layout with a Row to hold buttons and content
21
  with gr.Row():
22
  with gr.Column(scale=1, elem_classes=["menu-column"]):
 
34
  yoga_video_content = yoga_position_from_video()
35
 
36
  # Set initial visibility
37
+ home_page_content.visible = True
38
+ about_page_content.visible = False
39
+ yoga_stream_content.visible = False
40
+ yoga_video_content.visible = False
41
 
42
  # Button click handlers
43
+ def show_page(page):
44
+ return [
45
+ gr.update(visible=(content == page))
46
+ for content in [
47
+ home_page_content,
48
+ about_page_content,
49
+ yoga_stream_content,
50
+ yoga_video_content,
51
+ ]
52
+ ]
53
+
54
+ home_button.click(
55
+ lambda: show_page(home_page_content),
56
+ outputs=[
57
+ home_page_content,
58
+ about_page_content,
59
+ yoga_stream_content,
60
+ yoga_video_content,
61
+ ],
62
+ )
63
+ about_button.click(
64
+ lambda: show_page(about_page_content),
65
+ outputs=[
66
+ home_page_content,
67
+ about_page_content,
68
+ yoga_stream_content,
69
+ yoga_video_content,
70
+ ],
71
+ )
72
+ yoga_stream_button.click(
73
+ lambda: show_page(yoga_stream_content),
74
+ outputs=[
75
+ home_page_content,
76
+ about_page_content,
77
+ yoga_stream_content,
78
+ yoga_video_content,
79
+ ],
80
+ )
81
+ yoga_video_button.click(
82
+ lambda: show_page(yoga_video_content),
83
+ outputs=[
84
+ home_page_content,
85
+ about_page_content,
86
+ yoga_stream_content,
87
+ yoga_video_content,
88
+ ],
89
+ )
90
 
91
  return demo
92
 
93
 
94
  if __name__ == "__main__":
95
+ interface().launch(share=True)