IsemIsCold commited on
Commit
1f3f330
·
1 Parent(s): d0fb6af

Add theme selector with JavaScript reload

Browse files
Files changed (1) hide show
  1. app.py +46 -7
app.py CHANGED
@@ -481,6 +481,23 @@ def update_ui_for_language(lang):
481
  )
482
 
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  with gr.Blocks(
485
  title="IsemPoeticVoice",
486
  theme=gr.themes.Soft(),
@@ -490,13 +507,22 @@ with gr.Blocks(
490
  .rtl textarea, .rtl input { direction: rtl !important; text-align: right !important; }
491
  """,
492
  ) as demo:
493
- # Language selector
494
- lang_selector = gr.Dropdown(
495
- label="Language / اللغة",
496
- choices=["العربية", "English", "Français", "Español", "Türkçe"],
497
- value="العربية",
498
- interactive=True,
499
- )
 
 
 
 
 
 
 
 
 
500
 
501
  # Title and subtitle
502
  title_md = gr.Markdown(
@@ -602,6 +628,19 @@ with gr.Blocks(
602
  ],
603
  )
604
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605
  generate_button.click(
606
  fn=generate_poetry,
607
  inputs=[user_text, style, creativity],
 
481
  )
482
 
483
 
484
+ # Available themes
485
+ THEMES = {
486
+ "Soft": gr.themes.Soft(),
487
+ "Default": gr.themes.Default(),
488
+ "Monochrome": gr.themes.Monochrome(),
489
+ "Base": gr.themes.Base(),
490
+ "Glass": gr.themes.Glass(),
491
+ }
492
+
493
+ THEME_CSS = {
494
+ "Soft": "",
495
+ "Default": "",
496
+ "Monochrome": "",
497
+ "Base": "",
498
+ "Glass": "",
499
+ }
500
+
501
  with gr.Blocks(
502
  title="IsemPoeticVoice",
503
  theme=gr.themes.Soft(),
 
507
  .rtl textarea, .rtl input { direction: rtl !important; text-align: right !important; }
508
  """,
509
  ) as demo:
510
+ # Language and theme selectors
511
+ with gr.Row():
512
+ lang_selector = gr.Dropdown(
513
+ label="Language / اللغة",
514
+ choices=["العربية", "English", "Français", "Español", "Türkçe"],
515
+ value="العربية",
516
+ interactive=True,
517
+ scale=1,
518
+ )
519
+ theme_selector = gr.Dropdown(
520
+ label="Theme / المظهر",
521
+ choices=["Soft", "Default", "Monochrome", "Base", "Glass"],
522
+ value="Soft",
523
+ interactive=True,
524
+ scale=1,
525
+ )
526
 
527
  # Title and subtitle
528
  title_md = gr.Markdown(
 
628
  ],
629
  )
630
 
631
+ # Update theme when theme selector changes
632
+ theme_selector.change(
633
+ fn=None,
634
+ inputs=[theme_selector],
635
+ outputs=None,
636
+ js="""
637
+ function(theme) {
638
+ localStorage.setItem('gradio_theme', theme);
639
+ location.reload();
640
+ }
641
+ """,
642
+ )
643
+
644
  generate_button.click(
645
  fn=generate_poetry,
646
  inputs=[user_text, style, creativity],