NeoPy commited on
Commit
aa46056
·
verified ·
1 Parent(s): 815534b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +130 -14
app.py CHANGED
@@ -1,4 +1,6 @@
1
  from __future__ import annotations
 
 
2
 
3
  from typing import Iterable
4
  import gradio as gr
@@ -280,20 +282,134 @@ class Applio(Base):
280
  )
281
 
282
 
283
- def your_function(text):
284
- print(text)
285
- range = text
286
- return range
287
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
- # Assuming SimpleModern is your custom theme class
290
- demo = gr.Interface(
291
- fn=your_function,
292
- inputs=gr.Textbox(),
293
- outputs=gr.Textbox(),
294
- theme=Applio(),
295
- title="Test App",
296
- )
 
297
 
298
- demo.launch()
299
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from __future__ import annotations
2
+ import time
3
+ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
4
 
5
  from typing import Iterable
6
  import gradio as gr
 
282
  )
283
 
284
 
 
 
 
 
285
 
286
+ dropdown, js = create_theme_dropdown()
287
+ with gr.Blocks(theme=Applio()) as demo:
288
+ with gr.Row(equal_height=True):
289
+ with gr.Column(scale=10):
290
+ gr.Markdown(
291
+ """
292
+ # Test Theme
293
+ """
294
+ )
295
+ with gr.Column(scale=3):
296
+ with gr.Group():
297
+ dropdown.render()
298
+ toggle_dark = gr.Button(value="Toggle Dark")
299
 
300
+ dropdown.change(None, dropdown, None, js=js)
301
+ toggle_dark.click(
302
+ None,
303
+ js="""
304
+ () => {
305
+ document.body.classList.toggle('dark');
306
+ }
307
+ """,
308
+ )
309
 
310
+ name = gr.Textbox(
311
+ label="Name",
312
+ info="Full name, including middle name. No special characters.",
313
+ placeholder="John Doe",
314
+ value="John Doe",
315
+ interactive=True,
316
+ )
317
+
318
+ with gr.Row():
319
+ slider1 = gr.Slider(label="Slider 1")
320
+ slider2 = gr.Slider(label="Slider 2")
321
+ gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
322
+
323
+ with gr.Row():
324
+ with gr.Column(variant="panel", scale=1):
325
+ gr.Markdown("## Panel 1")
326
+ radio = gr.Radio(
327
+ ["A", "B", "C"],
328
+ label="Radio",
329
+ 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.",
330
+ )
331
+ drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
332
+ drop_2 = gr.Dropdown(
333
+ ["Option A", "Option B", "Option C"],
334
+ multiselect=True,
335
+ value=["Option A"],
336
+ label="Dropdown",
337
+ interactive=True,
338
+ )
339
+ check = gr.Checkbox(label="Go")
340
+ with gr.Column(variant="panel", scale=2):
341
+ img = gr.Image(
342
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg",
343
+ label="Image",
344
+ height=320,
345
+ )
346
+ with gr.Row():
347
+ go_btn = gr.Button("Go", variant="primary")
348
+ clear_btn = gr.Button("Clear", variant="secondary")
349
+
350
+ def go(*_args):
351
+ time.sleep(3)
352
+ return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg"
353
+
354
+ go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
355
+
356
+ def clear():
357
+ time.sleep(0.2)
358
+
359
+ clear_btn.click(clear, None, img)
360
+
361
+ with gr.Row():
362
+ btn1 = gr.Button("Button 1", size="sm")
363
+ btn2 = gr.UploadButton(size="sm")
364
+ stop_btn = gr.Button("Stop", size="sm", variant="stop")
365
+
366
+ with gr.Row():
367
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
368
+ gr.JSON(
369
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
370
+ )
371
+ gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
372
+ gr.File()
373
+ with gr.Row():
374
+ gr.ColorPicker()
375
+ gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
376
+ gr.Gallery(
377
+ [
378
+ (
379
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
380
+ "lion",
381
+ ),
382
+ (
383
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
384
+ "logo",
385
+ ),
386
+ (
387
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
388
+ "tower",
389
+ ),
390
+ ],
391
+ height=200,
392
+ )
393
+
394
+ with gr.Row():
395
+ with gr.Column(scale=2):
396
+ chatbot = gr.Chatbot([("Hello", "Hi")], label="Chatbot")
397
+ chat_btn = gr.Button("Add messages")
398
+
399
+ chat_btn.click(
400
+ lambda history: history
401
+ + [["How are you?", "I am good."]]
402
+ + (time.sleep(2) or []),
403
+ chatbot,
404
+ chatbot,
405
+ )
406
+ with gr.Column(scale=1):
407
+ with gr.Accordion("Advanced Settings"):
408
+ gr.Markdown("Hello")
409
+ gr.Number(label="Chatbot control 1")
410
+ gr.Number(label="Chatbot control 2")
411
+ gr.Number(label="Chatbot control 3")
412
+
413
+
414
+ if __name__ == "__main__":
415
+ demo.queue().launch()