Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,32 @@
|
|
| 1 |
import time
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
-
from theme_dropdown import create_theme_dropdown
|
| 5 |
|
| 6 |
dropdown, js = create_theme_dropdown()
|
| 7 |
|
| 8 |
-
with gr.Blocks(theme='
|
| 9 |
-
with gr.Row(
|
| 10 |
with gr.Column(scale=10):
|
| 11 |
gr.Markdown(
|
| 12 |
"""
|
| 13 |
-
# Theme preview: `
|
| 14 |
-
To use this theme, set `theme='
|
| 15 |
You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
|
| 16 |
of this theme.
|
| 17 |
"""
|
| 18 |
)
|
| 19 |
with gr.Column(scale=3):
|
| 20 |
-
with gr.
|
| 21 |
dropdown.render()
|
| 22 |
-
toggle_dark = gr.Button(value="Toggle Dark")
|
| 23 |
|
| 24 |
-
dropdown.change(None, dropdown, None,
|
| 25 |
toggle_dark.click(
|
| 26 |
None,
|
| 27 |
-
|
| 28 |
() => {
|
| 29 |
document.body.classList.toggle('dark');
|
| 30 |
-
document.querySelector('gradio-app').style.backgroundColor = 'var(--color-background-primary)'
|
| 31 |
}
|
| 32 |
""",
|
| 33 |
)
|
|
@@ -64,32 +63,29 @@ with gr.Blocks(theme='abidlabs/dracula_test') as demo:
|
|
| 64 |
check = gr.Checkbox(label="Go")
|
| 65 |
with gr.Column(variant="panel", scale=2):
|
| 66 |
img = gr.Image(
|
| 67 |
-
"https://gradio.
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
with gr.Row():
|
| 70 |
-
go_btn = gr.Button("Go",
|
| 71 |
-
clear_btn = gr.Button(
|
| 72 |
-
"Clear", label="Secondary Button", variant="secondary"
|
| 73 |
-
)
|
| 74 |
|
| 75 |
-
def go(*
|
| 76 |
time.sleep(3)
|
| 77 |
-
return "https://gradio.
|
| 78 |
|
| 79 |
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
| 80 |
|
| 81 |
def clear():
|
| 82 |
time.sleep(0.2)
|
| 83 |
-
return None
|
| 84 |
|
| 85 |
clear_btn.click(clear, None, img)
|
| 86 |
|
| 87 |
with gr.Row():
|
| 88 |
-
btn1 = gr.Button("Button 1"
|
| 89 |
-
btn2 = gr.UploadButton(
|
| 90 |
-
stop_btn = gr.Button("Stop",
|
| 91 |
-
size="sm"
|
| 92 |
-
)
|
| 93 |
|
| 94 |
with gr.Row():
|
| 95 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
|
@@ -115,18 +111,15 @@ with gr.Blocks(theme='abidlabs/dracula_test') as demo:
|
|
| 115 |
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
| 116 |
"tower",
|
| 117 |
),
|
| 118 |
-
]
|
| 119 |
-
|
|
|
|
| 120 |
|
| 121 |
with gr.Row():
|
| 122 |
with gr.Column(scale=2):
|
| 123 |
chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
|
| 124 |
chat_btn = gr.Button("Add messages")
|
| 125 |
|
| 126 |
-
def chat(history):
|
| 127 |
-
time.sleep(2)
|
| 128 |
-
yield [["How are you?", "I am good."]]
|
| 129 |
-
|
| 130 |
chat_btn.click(
|
| 131 |
lambda history: history
|
| 132 |
+ [["How are you?", "I am good."]]
|
|
|
|
| 1 |
import time
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from theme_dropdown import create_theme_dropdown
|
| 5 |
|
| 6 |
dropdown, js = create_theme_dropdown()
|
| 7 |
|
| 8 |
+
with gr.Blocks(theme='NeoPy/dracula', js="() => {document.body.classList.toggle('dark');}") as demo:
|
| 9 |
+
with gr.Row(equal_height=True):
|
| 10 |
with gr.Column(scale=10):
|
| 11 |
gr.Markdown(
|
| 12 |
"""
|
| 13 |
+
# Theme preview: `dracula`
|
| 14 |
+
To use this theme, set `theme='NeoPy/dracula'` in `gr.Blocks()` or `gr.Interface()`.
|
| 15 |
You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
|
| 16 |
of this theme.
|
| 17 |
"""
|
| 18 |
)
|
| 19 |
with gr.Column(scale=3):
|
| 20 |
+
with gr.Group():
|
| 21 |
dropdown.render()
|
| 22 |
+
toggle_dark = gr.Button(value="Toggle Dark")
|
| 23 |
|
| 24 |
+
dropdown.change(None, dropdown, None, js=js)
|
| 25 |
toggle_dark.click(
|
| 26 |
None,
|
| 27 |
+
js="""
|
| 28 |
() => {
|
| 29 |
document.body.classList.toggle('dark');
|
|
|
|
| 30 |
}
|
| 31 |
""",
|
| 32 |
)
|
|
|
|
| 63 |
check = gr.Checkbox(label="Go")
|
| 64 |
with gr.Column(variant="panel", scale=2):
|
| 65 |
img = gr.Image(
|
| 66 |
+
"https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg",
|
| 67 |
+
label="Image",
|
| 68 |
+
height=320,
|
| 69 |
+
)
|
| 70 |
with gr.Row():
|
| 71 |
+
go_btn = gr.Button("Go", variant="primary")
|
| 72 |
+
clear_btn = gr.Button("Clear", variant="secondary")
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
def go(*_args):
|
| 75 |
time.sleep(3)
|
| 76 |
+
return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg"
|
| 77 |
|
| 78 |
go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
|
| 79 |
|
| 80 |
def clear():
|
| 81 |
time.sleep(0.2)
|
|
|
|
| 82 |
|
| 83 |
clear_btn.click(clear, None, img)
|
| 84 |
|
| 85 |
with gr.Row():
|
| 86 |
+
btn1 = gr.Button("Button 1", size="sm")
|
| 87 |
+
btn2 = gr.UploadButton(size="sm")
|
| 88 |
+
stop_btn = gr.Button("Stop", size="sm", variant="stop")
|
|
|
|
|
|
|
| 89 |
|
| 90 |
with gr.Row():
|
| 91 |
gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
|
|
|
|
| 111 |
"https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
|
| 112 |
"tower",
|
| 113 |
),
|
| 114 |
+
],
|
| 115 |
+
height=200,
|
| 116 |
+
)
|
| 117 |
|
| 118 |
with gr.Row():
|
| 119 |
with gr.Column(scale=2):
|
| 120 |
chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
|
| 121 |
chat_btn = gr.Button("Add messages")
|
| 122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
chat_btn.click(
|
| 124 |
lambda history: history
|
| 125 |
+ [["How are you?", "I am good."]]
|