Respair commited on
Commit
c97e8ee
·
verified ·
1 Parent(s): 9ba5d35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +157 -157
app.py CHANGED
@@ -1,147 +1,3 @@
1
- import time
2
-
3
- import gradio as gr
4
- from gradio.themes.utils.theme_dropdown import create_theme_dropdown
5
-
6
- dropdown, js = create_theme_dropdown()
7
-
8
- with gr.Blocks(theme='Respair/[email protected]') as demo:
9
- with gr.Row():
10
- with gr.Column(scale=10):
11
- gr.Markdown(
12
- """
13
- # Theme preview: `Shiki`
14
- To use this theme, set `theme='Respair/[email protected]'` or `theme='Respair/[email protected]'` in `gr.Blocks()` or `gr.Interface()`.
15
- of this theme.
16
- """
17
- )
18
- # with gr.Column(scale=3):
19
- # with gr.Box():
20
- # dropdown.render()
21
- # toggle_dark = gr.Button(value="Toggle Dark")
22
-
23
- dropdown.change(None, dropdown, None, _js=js)
24
- toggle_dark.click(
25
- None,
26
- _js="""
27
- () => {
28
- document.body.classList.toggle('dark');
29
- }
30
- """,
31
- )
32
-
33
- name = gr.Textbox(
34
- label="Name",
35
- info="Full name, including middle name. No special characters.",
36
- placeholder="John Doe",
37
- value="John Doe",
38
- interactive=True,
39
- )
40
-
41
- with gr.Row():
42
- slider1 = gr.Slider(label="Slider 1")
43
- slider2 = gr.Slider(label="Slider 2")
44
- gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
45
-
46
- with gr.Row():
47
- with gr.Column(variant="panel", scale=1):
48
- gr.Markdown("## Panel 1")
49
- radio = gr.Radio(
50
- ["A", "B", "C"],
51
- label="Radio",
52
- 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.",
53
- )
54
- drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
55
- drop_2 = gr.Dropdown(
56
- ["Option A", "Option B", "Option C"],
57
- multiselect=True,
58
- value=["Option A"],
59
- label="Dropdown",
60
- interactive=True,
61
- )
62
- check = gr.Checkbox(label="Go")
63
- with gr.Column(variant="panel", scale=2):
64
- img = gr.Image(
65
- "https://i.ibb.co/ydPm3n8/download-12-0.webp",
66
- label="Image",
67
- )
68
- with gr.Row():
69
- go_btn = gr.Button("Go", label="Primary Button", variant="primary")
70
- clear_btn = gr.Button(
71
- "Clear", label="Secondary Button", variant="secondary"
72
- )
73
-
74
- def go(*args):
75
- time.sleep(3)
76
- return "https://i.ibb.co/ydPm3n8/download-12-0.webp"
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
- return None
83
-
84
- clear_btn.click(clear, None, img)
85
-
86
- with gr.Row():
87
- btn1 = gr.Button("Button 1")
88
- btn2 = gr.UploadButton()
89
- stop_btn = gr.Button("Stop", label="Stop Button", variant="stop")
90
- with gr.Row():
91
- gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
92
- gr.JSON(
93
- value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
94
- )
95
- gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
96
- gr.File()
97
- with gr.Row():
98
- gr.ColorPicker()
99
- gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
100
- gr.Gallery(
101
- [
102
- (
103
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
104
- "lion",
105
- ),
106
- (
107
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
108
- "logo",
109
- ),
110
- (
111
- "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
112
- "tower",
113
- ),
114
- ]
115
- )
116
-
117
- with gr.Row():
118
- with gr.Column(scale=2):
119
- chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
120
- chat_btn = gr.Button("Add messages")
121
-
122
- def chat(history):
123
- time.sleep(2)
124
- yield [["How are you?", "I am good."]]
125
-
126
- chat_btn.click(
127
- lambda history: history
128
- + [["How are you?", "I am good."]]
129
- + (time.sleep(2) or []),
130
- chatbot,
131
- chatbot,
132
- )
133
- with gr.Column(scale=1):
134
- with gr.Accordion("Advanced Settings"):
135
- gr.Markdown("Hello")
136
- gr.Number(label="Chatbot control 1")
137
- gr.Number(label="Chatbot control 2")
138
- gr.Number(label="Chatbot control 3")
139
-
140
-
141
- if __name__ == "__main__":
142
- demo.queue().launch()
143
-
144
-
145
  # import time
146
 
147
  # import gradio as gr
@@ -150,7 +6,7 @@ if __name__ == "__main__":
150
  # dropdown, js = create_theme_dropdown()
151
 
152
  # with gr.Blocks(theme='Respair/[email protected]') as demo:
153
- # with gr.Row().style(equal_height=True):
154
  # with gr.Column(scale=10):
155
  # gr.Markdown(
156
  # """
@@ -159,10 +15,10 @@ if __name__ == "__main__":
159
  # of this theme.
160
  # """
161
  # )
162
- # with gr.Column(scale=3):
163
- # with gr.Box():
164
- # dropdown.render()
165
- # toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
166
 
167
  # dropdown.change(None, dropdown, None, _js=js)
168
  # toggle_dark.click(
@@ -208,7 +64,7 @@ if __name__ == "__main__":
208
  # img = gr.Image(
209
  # "https://i.ibb.co/ydPm3n8/download-12-0.webp",
210
  # label="Image",
211
- # ).style(height=320)
212
  # with gr.Row():
213
  # go_btn = gr.Button("Go", label="Primary Button", variant="primary")
214
  # clear_btn = gr.Button(
@@ -228,12 +84,9 @@ if __name__ == "__main__":
228
  # clear_btn.click(clear, None, img)
229
 
230
  # with gr.Row():
231
- # btn1 = gr.Button("Button 1").style(size="sm")
232
- # btn2 = gr.UploadButton().style(size="sm")
233
- # stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
234
- # size="sm"
235
- # )
236
-
237
  # with gr.Row():
238
  # gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
239
  # gr.JSON(
@@ -259,7 +112,7 @@ if __name__ == "__main__":
259
  # "tower",
260
  # ),
261
  # ]
262
- # ).style(height="200px", grid=2)
263
 
264
  # with gr.Row():
265
  # with gr.Column(scale=2):
@@ -288,3 +141,150 @@ if __name__ == "__main__":
288
  # if __name__ == "__main__":
289
  # demo.queue().launch()
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # import time
2
 
3
  # import gradio as gr
 
6
  # dropdown, js = create_theme_dropdown()
7
 
8
  # with gr.Blocks(theme='Respair/[email protected]') as demo:
9
+ # with gr.Row():
10
  # with gr.Column(scale=10):
11
  # gr.Markdown(
12
  # """
 
15
  # of this theme.
16
  # """
17
  # )
18
+ # # with gr.Column(scale=3):
19
+ # # with gr.Box():
20
+ # # dropdown.render()
21
+ # # toggle_dark = gr.Button(value="Toggle Dark")
22
 
23
  # dropdown.change(None, dropdown, None, _js=js)
24
  # toggle_dark.click(
 
64
  # img = gr.Image(
65
  # "https://i.ibb.co/ydPm3n8/download-12-0.webp",
66
  # label="Image",
67
+ # )
68
  # with gr.Row():
69
  # go_btn = gr.Button("Go", label="Primary Button", variant="primary")
70
  # clear_btn = gr.Button(
 
84
  # clear_btn.click(clear, None, img)
85
 
86
  # with gr.Row():
87
+ # btn1 = gr.Button("Button 1")
88
+ # btn2 = gr.UploadButton()
89
+ # stop_btn = gr.Button("Stop", label="Stop Button", variant="stop")
 
 
 
90
  # with gr.Row():
91
  # gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
92
  # gr.JSON(
 
112
  # "tower",
113
  # ),
114
  # ]
115
+ # )
116
 
117
  # with gr.Row():
118
  # with gr.Column(scale=2):
 
141
  # if __name__ == "__main__":
142
  # demo.queue().launch()
143
 
144
+
145
+ import time
146
+
147
+ import gradio as gr
148
+ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
149
+
150
+ dropdown, js = create_theme_dropdown()
151
+
152
+ with gr.Blocks(theme='Respair/[email protected]') as demo:
153
+ with gr.Row().style(equal_height=True):
154
+ with gr.Column(scale=10):
155
+ gr.Markdown(
156
+ """
157
+ # Theme preview: `Shiki`
158
+ To use this theme, set `theme='Respair/[email protected]'` or `theme='Respair/[email protected]'` in `gr.Blocks()` or `gr.Interface()`.
159
+ of this theme.
160
+ """
161
+ )
162
+ with gr.Column(scale=3):
163
+ with gr.Box():
164
+ dropdown.render()
165
+ toggle_dark = gr.Button(value="Toggle Dark").style(full_width=True)
166
+
167
+ dropdown.change(None, dropdown, None, _js=js)
168
+ toggle_dark.click(
169
+ None,
170
+ _js="""
171
+ () => {
172
+ document.body.classList.toggle('dark');
173
+ }
174
+ """,
175
+ )
176
+
177
+ name = gr.Textbox(
178
+ label="Name",
179
+ info="Full name, including middle name. No special characters.",
180
+ placeholder="John Doe",
181
+ value="John Doe",
182
+ interactive=True,
183
+ )
184
+
185
+ with gr.Row():
186
+ slider1 = gr.Slider(label="Slider 1")
187
+ slider2 = gr.Slider(label="Slider 2")
188
+ gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
189
+
190
+ with gr.Row():
191
+ with gr.Column(variant="panel", scale=1):
192
+ gr.Markdown("## Panel 1")
193
+ radio = gr.Radio(
194
+ ["A", "B", "C"],
195
+ label="Radio",
196
+ 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.",
197
+ )
198
+ drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
199
+ drop_2 = gr.Dropdown(
200
+ ["Option A", "Option B", "Option C"],
201
+ multiselect=True,
202
+ value=["Option A"],
203
+ label="Dropdown",
204
+ interactive=True,
205
+ )
206
+ check = gr.Checkbox(label="Go")
207
+ with gr.Column(variant="panel", scale=2):
208
+ img = gr.Image(
209
+ "https://i.ibb.co/ydPm3n8/download-12-0.webp",
210
+ label="Image",
211
+ ).style(height=320)
212
+ with gr.Row():
213
+ go_btn = gr.Button("Go", label="Primary Button", variant="primary")
214
+ clear_btn = gr.Button(
215
+ "Clear", label="Secondary Button", variant="secondary"
216
+ )
217
+
218
+ def go(*args):
219
+ time.sleep(3)
220
+ return "https://i.ibb.co/ydPm3n8/download-12-0.webp"
221
+
222
+ go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
223
+
224
+ def clear():
225
+ time.sleep(0.2)
226
+ return None
227
+
228
+ clear_btn.click(clear, None, img)
229
+
230
+ with gr.Row():
231
+ btn1 = gr.Button("Button 1").style(size="sm")
232
+ btn2 = gr.UploadButton().style(size="sm")
233
+ stop_btn = gr.Button("Stop", label="Stop Button", variant="stop").style(
234
+ size="sm"
235
+ )
236
+
237
+ with gr.Row():
238
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
239
+ gr.JSON(
240
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
241
+ )
242
+ gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
243
+ gr.File()
244
+ with gr.Row():
245
+ gr.ColorPicker()
246
+ gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
247
+ gr.Gallery(
248
+ [
249
+ (
250
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
251
+ "lion",
252
+ ),
253
+ (
254
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
255
+ "logo",
256
+ ),
257
+ (
258
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
259
+ "tower",
260
+ ),
261
+ ]
262
+ ).style(height="200px", grid=2)
263
+
264
+ with gr.Row():
265
+ with gr.Column(scale=2):
266
+ chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
267
+ chat_btn = gr.Button("Add messages")
268
+
269
+ def chat(history):
270
+ time.sleep(2)
271
+ yield [["How are you?", "I am good."]]
272
+
273
+ chat_btn.click(
274
+ lambda history: history
275
+ + [["How are you?", "I am good."]]
276
+ + (time.sleep(2) or []),
277
+ chatbot,
278
+ chatbot,
279
+ )
280
+ with gr.Column(scale=1):
281
+ with gr.Accordion("Advanced Settings"):
282
+ gr.Markdown("Hello")
283
+ gr.Number(label="Chatbot control 1")
284
+ gr.Number(label="Chatbot control 2")
285
+ gr.Number(label="Chatbot control 3")
286
+
287
+
288
+ if __name__ == "__main__":
289
+ demo.queue().launch()
290
+