Next
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
import gradio as gr
|
4 |
+
from gradio.themes.base import Base
|
5 |
+
from gradio.themes.utils import colors, fonts, sizes
|
6 |
+
import time
|
7 |
+
|
8 |
+
|
9 |
+
class BlueTheme(Base):
|
10 |
+
def __init__(
|
11 |
+
self,
|
12 |
+
*,
|
13 |
+
primary_hue: colors.Color | str = colors.blue,
|
14 |
+
secondary_hue: colors.Color | str = colors.blue,
|
15 |
+
neutral_hue: colors.Color | str = colors.gray,
|
16 |
+
spacing_size: sizes.Size | str = sizes.spacing_md,
|
17 |
+
radius_size: sizes.Size | str = sizes.radius_md,
|
18 |
+
text_size: sizes.Size | str = sizes.text_lg,
|
19 |
+
font: fonts.Font
|
20 |
+
| str
|
21 |
+
| Iterable[fonts.Font | str] = (
|
22 |
+
fonts.GoogleFont("Quicksand"),
|
23 |
+
"ui-sans-serif",
|
24 |
+
"sans-serif",
|
25 |
+
),
|
26 |
+
font_mono: fonts.Font
|
27 |
+
| str
|
28 |
+
| Iterable[fonts.Font | str] = (
|
29 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
30 |
+
"ui-monospace",
|
31 |
+
"monospace",
|
32 |
+
),
|
33 |
+
):
|
34 |
+
super().__init__(
|
35 |
+
primary_hue=primary_hue,
|
36 |
+
secondary_hue=secondary_hue,
|
37 |
+
neutral_hue=neutral_hue,
|
38 |
+
spacing_size=spacing_size,
|
39 |
+
radius_size=radius_size,
|
40 |
+
text_size=text_size,
|
41 |
+
font=font,
|
42 |
+
font_mono=font_mono,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
blue_theme = BlueTheme()
|
47 |
+
|
48 |
+
with gr.Blocks(theme=blue_theme) as demo:
|
49 |
+
textbox = gr.Textbox(label="Name")
|
50 |
+
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
|
51 |
+
with gr.Row():
|
52 |
+
button = gr.Button("Submit", variant="primary")
|
53 |
+
clear = gr.Button("Clear")
|
54 |
+
output = gr.Textbox(label="Output")
|
55 |
+
|
56 |
+
def repeat(name, count):
|
57 |
+
time.sleep(3)
|
58 |
+
return name * count
|
59 |
+
|
60 |
+
button.click(repeat, [textbox, slider], output)
|
61 |
+
|
62 |
+
demo.launch()
|