Spaces:
Nymbo
/
Runtime error

Rooni commited on
Commit
75547e4
1 Parent(s): 8bbc8d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -138
app.py CHANGED
@@ -1,148 +1,30 @@
1
- import time
2
-
3
  import gradio as gr
4
 
5
- from gradio.themes.utils.theme_dropdown import create_theme_dropdown
6
-
7
- dropdown, js = create_theme_dropdown()
8
-
9
-
10
- THEME = 'YTheme/GMaterial'
11
- with gr.Blocks(theme=THEME) as demo:
12
  with gr.Row():
13
- with gr.Column(scale=10):
14
- gr.Markdown(
15
- f"""
16
- # Theme preview: `{THEME}`
17
- To use this theme, set `theme='{THEME}'` in `gr.Blocks()` or `gr.Interface()`.
18
- You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
19
- of this theme.
20
- """
21
- )
22
- with gr.Column(scale=3):
23
- with gr.Box():
24
- dropdown.render()
25
- toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
26
-
27
- dropdown.change(None, dropdown, None, _js=js)
28
- toggle_dark.click(
29
- None,
30
- _js="""
31
- () => {
32
- document.body.classList.toggle('dark');
33
- }
34
- """,
35
- )
36
-
37
- name = gr.Textbox(
38
- label="Name",
39
- info="Full name, including middle name. No special characters.",
40
- placeholder="John Doe",
41
- value="John Doe",
42
- interactive=True,
43
- )
44
-
45
  with gr.Row():
46
- slider1 = gr.Slider(label="Slider 1")
47
- slider2 = gr.Slider(label="Slider 2")
48
- gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
49
-
 
50
  with gr.Row():
51
- with gr.Column(variant="panel", scale=1):
52
- gr.Markdown("## Panel 1")
53
- radio = gr.Radio(
54
- ["A", "B", "C"],
55
- label="Radio",
56
- info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
57
- )
58
- drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
59
- drop_2 = gr.Dropdown(
60
- ["Option A", "Option B", "Option C"],
61
- multiselect=True,
62
- value=["Option A"],
63
- label="Dropdown",
64
- interactive=True,
65
- )
66
- check = gr.Checkbox(label="Go")
67
- with gr.Column(variant="panel", scale=2):
68
- img = gr.Image(
69
- f"https://huggingface.co/spaces/{THEME}/resolve/main/header-image.jpg", label="Image"
70
- ).style(height=320)
71
- with gr.Row():
72
- go_btn = gr.Button("Go", label="Primary Button", variant="primary")
73
- clear_btn = gr.Button(
74
- "Clear", label="Secondary Button", variant="secondary"
75
- )
76
-
77
- def go(*args):
78
- time.sleep(3)
79
- return f"https://huggingface.co/spaces/{THEME}/resolve/main/header-image.jpg"
80
-
81
- go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
82
-
83
- def clear():
84
- time.sleep(0.2)
85
- return None
86
-
87
- clear_btn.click(clear, None, img)
88
-
89
- with gr.Row():
90
- btn1 = gr.Button("Button 1").style(size="sm")
91
- btn2 = gr.UploadButton().style(size="sm")
92
- stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
93
- size="sm"
94
- )
95
-
96
  with gr.Row():
97
- gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
98
- gr.JSON(
99
- value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
100
- )
101
- gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
102
- gr.File()
103
  with gr.Row():
104
- gr.ColorPicker()
105
- gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
106
- gr.Gallery(
107
- [
108
- (
109
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
110
- "lion",
111
- ),
112
- (
113
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
114
- "logo",
115
- ),
116
- (
117
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
118
- "tower",
119
- ),
120
- ]
121
- ).style(height="200px", grid=2)
122
-
123
  with gr.Row():
124
- with gr.Column(scale=2):
125
- chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
126
- chat_btn = gr.Button("Add messages")
127
-
128
- def chat(history):
129
- time.sleep(2)
130
- yield [["How are you?", "I am good."]]
131
-
132
- chat_btn.click(
133
- lambda history: history
134
- + [["How are you?", "I am good."]]
135
- + (time.sleep(2) or []),
136
- chatbot,
137
- chatbot,
138
- )
139
- with gr.Column(scale=1):
140
- with gr.Accordion("Advanced Settings"):
141
- gr.Markdown("Hello")
142
- gr.Number(label="Chatbot control 1")
143
- gr.Number(label="Chatbot control 2")
144
- gr.Number(label="Chatbot control 3")
145
-
146
 
147
  if __name__ == "__main__":
148
- demo.queue().launch()
 
 
 
1
  import gradio as gr
2
 
3
+ with gr.Blocks(theme='YTheme/GMaterial') as demo:
 
 
 
 
 
 
4
  with gr.Row():
5
+ gr.Markdown("# Предпросмотр темы: `YTheme/GMaterial`"
6
+ " Чтобы использовать эту тему, установите `theme='YTheme/PastelDark'` в `gr.Blocks()` или `gr.Interface()`."
7
+ " Вы можете добавить `@` и выражение семантической версии, например, @>=1.0.0,<2.0.0, чтобы закрепить за собой данную версию"
8
+ " темы.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  with gr.Row():
10
+ with gr.Column():
11
+ gr.Markdown("### Пример Markdown")
12
+ gr.Textbox(label="Текстовое поле")
13
+ with gr.Column():
14
+ gr.Image(value="https://via.placeholder.com/150", label="Пример изображения")
15
  with gr.Row():
16
+ gr.Button("Кнопка")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  with gr.Row():
18
+ gr.Checkbox(label="Чекбокс")
 
 
 
 
 
19
  with gr.Row():
20
+ with gr.Column():
21
+ gr.Radio(choices=["Опция 1", "Опция 2"], label="Радио кнопки")
22
+ with gr.Column():
23
+ gr.Dropdown(choices=["Выбор 1", "Выбор 2"], label="Выпадающий список")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  with gr.Row():
25
+ gr.Slider(minimum=0, maximum=10, label="Ползунок")
26
+ with gr.Row():
27
+ gr.TextArea(label="Многострочное текстовое поле")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  if __name__ == "__main__":
30
+ demo.launch()