File size: 1,672 Bytes
de53991
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import gradio as gr
import numpy as np

def page1():
    with gr.Group():
        gr.Markdown("# Page 1 Content")
        input_text = gr.Textbox(label="Enter some text")
        output_text = gr.Textbox(label="Output")
        button = gr.Button("Process")
        
        def process_text(text):
            return text.upper()
        
        button.click(fn=process_text, inputs=input_text, outputs=output_text)

def page2():
    with gr.Group():
        gr.Markdown("# Page 2 Content")
        num1 = gr.Number(label="Number 1")
        num2 = gr.Number(label="Number 2")
        result = gr.Number(label="Result")
        add_btn = gr.Button("Add")
        
        def add_numbers(a, b):
            return a + b
        
        add_btn.click(fn=add_numbers, inputs=[num1, num2], outputs=result)

def page3():
    with gr.Group():
        gr.Markdown("# Page 3 Content")
        image_input = gr.Image()
        image_output = gr.Image()
        flip_btn = gr.Button("Flip Image")
        
        def flip_image(img):
            return np.fliplr(img) if img is not None else None
        
        flip_btn.click(fn=flip_image, inputs=image_input, outputs=image_output)

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column(scale=1):
            # Sidebar
            gr.Markdown("### Navigation")
        
        with gr.Column(scale=4):
            # Main content area using Tabs
            with gr.Tabs() as tabs:
                with gr.TabItem("Page 1"):
                    page1()
                with gr.TabItem("Page 2"):
                    page2()
                with gr.TabItem("Page 3"):
                    page3()

demo.launch()