aliabd HF Staff commited on
Commit
d22121c
·
1 Parent(s): e4dde1d

Upload with huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +6 -6
  2. app.py +36 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Blocks Plug
3
- emoji: 🏃
4
- colorFrom: green
5
- colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.3.1
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: blocks_plug
4
+ emoji: 🔥
5
+ colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 3.3.1
9
+
10
  app_file: app.py
11
  pinned: false
12
  ---
 
 
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+
4
+ def change_tab():
5
+ return gr.Tabs.update(selected=2)
6
+
7
+
8
+ identity_demo, input_demo, output_demo = gr.Blocks(), gr.Blocks(), gr.Blocks()
9
+
10
+ with identity_demo:
11
+ gr.Interface(lambda x: x, "text", "text")
12
+
13
+ with input_demo:
14
+ t = gr.Textbox(label="Enter your text here")
15
+ with gr.Row():
16
+ btn = gr.Button("Submit")
17
+ clr = gr.Button("Clear")
18
+ clr.click(lambda x: "", t, t)
19
+
20
+ with output_demo:
21
+ gr.Textbox("This is a static output")
22
+
23
+ with gr.Blocks() as demo:
24
+ gr.Markdown("Three demos in one!")
25
+ with gr.Tabs(selected=1) as tabs:
26
+ with gr.TabItem("Text Identity", id=0):
27
+ identity_demo.render()
28
+ with gr.TabItem("Text Input", id=1):
29
+ input_demo.render()
30
+ with gr.TabItem("Text Static", id=2):
31
+ output_demo.render()
32
+ btn = gr.Button("Change tab")
33
+ btn.click(inputs=None, outputs=tabs, fn=change_tab)
34
+
35
+ if __name__ == "__main__":
36
+ demo.launch()