File size: 1,214 Bytes
90ee73b
 
31a1088
a447e83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr


with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column(visible=False, min_width=200, scale=0) as sidebar:
            btn1 = gr.Button("Button 1")
            btn2 = gr.Button("Button 2")
        with gr.Column() as main:
            open_sidebar_btn = gr.Button("Open Sidebar", scale=0)
            close_sidebar_btn = gr.Button("Close Sidebar", visible=False, scale=0)
            open_sidebar_btn.click(lambda: {
                open_sidebar_btn: gr.Button(visible=False),
                close_sidebar_btn: gr.Button(visible=True),
                sidebar: gr.Column(visible=True)
            }, outputs={open_sidebar_btn, close_sidebar_btn, sidebar})
            close_sidebar_btn.click(lambda: {
                open_sidebar_btn: gr.Button(visible=True),
                close_sidebar_btn: gr.Button(visible=False),
                sidebar: gr.Column(visible=False)
            }, outputs={open_sidebar_btn, close_sidebar_btn, sidebar})
            gr.Markdown("# Hello Blocks")
            gr.Markdown("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam nec nulla nec nulla fermentum fermentum. Nullam nec nulla nec nulla fermentum fermentum.")

demo.launch()