Spaces:
Sleeping
Sleeping
Upload with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -6,7 +6,6 @@ colorFrom: indigo
|
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.4.1
|
| 9 |
-
|
| 10 |
-
app_file: app.py
|
| 11 |
pinned: false
|
| 12 |
---
|
|
|
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.4.1
|
| 9 |
+
app_file: run.py
|
|
|
|
| 10 |
pinned: false
|
| 11 |
---
|
run.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()
|