Spaces:
Sleeping
Sleeping
Switch to Tabs instead of Columns - simpler navigation
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162"""Minimal test - 5 simple pages"""import gradio as grwith gr.Blocks(title="Test 5 Pages") as demo:# Page 1with gr.Column(visible=True) as page1:gr.Markdown("# ืขืืื 1 - ืืชืืื")gr.HTML("<p style='font-size:20px;'>ืืื ืืขืืื ืืจืืฉืื</p>")btn1 = gr.Button("โก๏ธ ืขืืื 2", variant="primary", size="lg")# Page 2with gr.Column(visible=False) as page2:gr.Markdown("# ืขืืื 2")gr.HTML("<p style='color:blue;'>โ ืืขืืจ 1 ืืฆืืื!</p>")btn2 = gr.Button("โก๏ธ ืขืืื 3", variant="primary", size="lg")# Page 3with gr.Column(visible=False) as page3:gr.Markdown("# ืขืืื 3")gr.HTML("<p style='color:green;'>โ โ ืืขืืจ 2 ืืฆืืื!</p>")btn3 = gr.Button("โก๏ธ ืขืืื 4", variant="primary", size="lg")# Page 4with gr.Column(visible=False) as page4:gr.Markdown("# ืขืืื 4")gr.HTML("<p style='color:orange;'>โ โ โ ืืขืืจ 3 ืืฆืืื!</p>")btn4 = gr.Button("โก๏ธ ืขืืื 5 (ืชืืฆืืืช)", variant="primary", size="lg")# Page 5 - Resultswith gr.Column(visible=False) as page5:gr.Markdown("# ๐ฏ ืขืืื 5 - ืชืืฆืืืช")gr.HTML("<h2 style='color:green;text-align:center;'>โ โ โ โ ืื ืืืขืืจืื ืขืืื!</h2>")gr.HTML("""<div style='padding:20px;background:#e8f5e9;border-radius:10px;margin-top:20px;'><h3>ืฆืืื: 100/100</h3><p>โ ืื 5 ืืขืืืืื ืขืืืืื ืืฆืืื!</p></div>""")def goto_page2():return (gr.update(visible=False), gr.update(visible=True),gr.update(visible=False), gr.update(visible=False), gr.update(visible=False))def goto_page3():return (gr.update(visible=False), gr.update(visible=False),gr.update(visible=True), gr.update(visible=False), gr.update(visible=False))def goto_page4():return (gr.update(visible=False), gr.update(visible=False),gr.update(visible=False), gr.update(visible=True), gr.update(visible=False))def goto_page5():return (gr.update(visible=False), gr.update(visible=False),gr.update(visible=False), gr.update(visible=False), gr.update(visible=True))btn1.click(fn=goto_page2, inputs=[], outputs=[page1, page2, page3, page4, page5])btn2.click(fn=goto_page3, inputs=[], outputs=[page1, page2, page3, page4, page5])btn3.click(fn=goto_page4, inputs=[], outputs=[page1, page2, page3, page4, page5])btn4.click(fn=goto_page5, inputs=[], outputs=[page1, page2, page3, page4, page5])demo.queue()123456789101112131415161718192021222324252627282930313233343536373839404142"""Minimal test - Using Tabs instead of Columns"""import gradio as grwith gr.Blocks(title="Test Navigation") as demo:with gr.Tabs() as tabs:with gr.Tab("ืขืืื 1", id=0):gr.Markdown("# ๐ ืขืืื 1 - ืืชืืื")gr.HTML("<p style='font-size:20px;'>ืืื ืืขืืื ืืจืืฉืื</p>")btn1 = gr.Button("โก๏ธ ืขืืื 2", variant="primary", size="lg")with gr.Tab("ืขืืื 2", id=1):gr.Markdown("# ๐ ืขืืื 2")gr.HTML("<p style='color:blue;font-size:18px;'>โ ืืขืืจ 1 ืืฆืืื!</p>")btn2 = gr.Button("โก๏ธ ืขืืื 3", variant="primary", size="lg")with gr.Tab("ืขืืื 3", id=2):gr.Markdown("# ๐ป ืขืืื 3")gr.HTML("<p style='color:green;font-size:18px;'>โ โ ืืขืืจ 2 ืืฆืืื!</p>")btn3 = gr.Button("โก๏ธ ืขืืื 4", variant="primary", size="lg")with gr.Tab("ืขืืื 4", id=3):gr.Markdown("# โ๏ธ ืขืืื 4")gr.HTML("<p style='color:orange;font-size:18px;'>โ โ โ ืืขืืจ 3 ืืฆืืื!</p>")btn4 = gr.Button("โก๏ธ ืขืืื 5 (ืชืืฆืืืช)", variant="primary", size="lg")with gr.Tab("ืชืืฆืืืช", id=4):gr.Markdown("# ๐ฏ ืขืืื 5 - ืชืืฆืืืช")gr.HTML("<h2 style='color:green;text-align:center;'>โ โ โ โ ืื ืืืขืืจืื ืขืืื!</h2>")gr.HTML("""<div style='padding:20px;background:#e8f5e9;border-radius:10px;margin-top:20px;'><h3>ืฆืืื: 100/100</h3><p>โ ืื 5 ืืขืืืืื ืขืืืืื ืืฆืืื!</p></div>""")btn1.click(fn=lambda: gr.Tabs(selected=1), inputs=[], outputs=[tabs])btn2.click(fn=lambda: gr.Tabs(selected=2), inputs=[], outputs=[tabs])btn3.click(fn=lambda: gr.Tabs(selected=3), inputs=[], outputs=[tabs])btn4.click(fn=lambda: gr.Tabs(selected=4), inputs=[], outputs=[tabs])demo.queue()
minimal_test.py+37-57