m-ric HF staff commited on
Commit
6124650
Β·
1 Parent(s): cb966df

Style errors

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -2,6 +2,13 @@ import gradio as gr
2
  import requests
3
  import pandas as pd
4
  import plotly.express as px
 
 
 
 
 
 
 
5
 
6
  class DownloadsTracker:
7
  def __init__(self):
@@ -42,15 +49,19 @@ class DownloadsTracker:
42
  df = self.all_packages[pkg]
43
  fig.add_scatter(x=df["date"], y=df["cumulative_downloads"], name=pkg)
44
 
45
- return fig, errors
46
 
47
  tracker = DownloadsTracker()
48
 
49
- with gr.Blocks() as app:
 
 
 
 
50
  packages = gr.Textbox("transformers", label="Package names (comma-separated)")
51
- error_box = gr.Textbox(label="Errors:", interactive=False)
52
  render_btn = gr.Button("Render")
53
  plot = gr.Plot()
54
- render_btn.click(tracker.plot, inputs=[packages], outputs=[plot, error_box])
55
 
56
  app.launch()
 
2
  import requests
3
  import pandas as pd
4
  import plotly.express as px
5
+ from gradio.themes import Soft
6
+
7
+ # theme.colors = Colors(
8
+ # error="#d92f2f",
9
+ # error_background="#fef2f2",
10
+ # background_fill_primary="#ffffff"
11
+ # )
12
 
13
  class DownloadsTracker:
14
  def __init__(self):
 
49
  df = self.all_packages[pkg]
50
  fig.add_scatter(x=df["date"], y=df["cumulative_downloads"], name=pkg)
51
 
52
+ return fig, errors, gr.update(visible=errors is not None)
53
 
54
  tracker = DownloadsTracker()
55
 
56
+ css = """
57
+ #textbox_id textarea {color: red}
58
+ #textbox_id span {background-color: red}
59
+ """
60
+ with gr.Blocks(theme=gr.themes.Soft(), css=css) as app:
61
  packages = gr.Textbox("transformers", label="Package names (comma-separated)")
62
+ error_box = gr.Textbox(label="Errors:", interactive=False, visible=False, elem_id="textbox_id")
63
  render_btn = gr.Button("Render")
64
  plot = gr.Plot()
65
+ render_btn.click(tracker.plot, inputs=[packages], outputs=[plot, error_box, error_box])
66
 
67
  app.launch()