anonymous12321 commited on
Commit
e18bf9d
·
verified ·
1 Parent(s): b60aa36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -45
app.py CHANGED
@@ -2,7 +2,7 @@
2
  # -*- coding: utf-8 -*-
3
  """
4
  🪶 Council Matters Classifier – PT
5
- Dark modern Gradio interface with suggestions box: title on top, arrows at bottom corners, "Use" button below.
6
  """
7
 
8
  import gradio as gr
@@ -170,7 +170,7 @@ def classify_display(text):
170
  chips += f"<span class='output-chip' style='border-color:{color}80;color:{color}'>{label} ({prob:.0%})</span>"
171
  return f"<div style='display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:10px'>{chips}</div>"
172
 
173
- # ---------------- CSS ----------------
174
  custom_css = """
175
  body { background-color: #0c0c0c; color: #f1f1f1; font-family: 'Inter', sans-serif; }
176
  .gradio-container { background-color: #0c0c0c; color: #f1f1f1; }
@@ -179,39 +179,18 @@ textarea { background-color: #181818 !important; color: #fff !important; border-
179
  button { background-color: #007aff !important; color: white !important; font-weight: 600 !important; border-radius: 8px !important; border: none !important; }
180
  button:hover { background-color: #00aaff !important; }
181
  .output-chip { background-color: #1a1a1a; padding: 5px 12px; border-radius: 8px; font-weight: 500; border: 1px solid #007aff33; }
182
-
183
- /* Caixa de sugestões */
184
  .suggestion-box {
185
  background-color: #112f50;
186
  border-radius: 10px;
187
  border: 1px solid #1f3c5a;
188
- padding: 15px;
189
- color: #eee;
190
- margin-top: 25px;
191
  display: flex;
192
- flex-direction: column;
193
  align-items: center;
194
- }
195
-
196
- /* Título das sugestões */
197
- .suggestion-box-title {
198
- font-weight: 600;
199
- margin-bottom: 8px;
200
- color: #00b4ff;
201
- }
202
-
203
- /* Texto da sugestão */
204
- .suggestion-box .suggestion-text {
205
- width: 100%;
206
- text-align: center;
207
- border: none;
208
- background: none;
209
  color: #eee;
210
- font-weight: 500;
211
- padding: 8px 0;
212
  }
213
-
214
- /* Botões */
215
  .arrow-btn {
216
  width: 25px;
217
  height: 25px;
@@ -224,16 +203,11 @@ button:hover { background-color: #00aaff !important; }
224
  font-weight: bold;
225
  }
226
  .arrow-btn:hover { color: #ffffff; transform: scale(1.3); }
227
- .use-btn { background-color:#66b3ff !important; color:#000 !important; font-weight:600 !important; border-radius:6px !important; padding:3px 8px !important; margin-top:10px;}
228
  .use-btn:hover { background-color:#99ccff !important; }
229
-
230
- /* Posicionamento das setas em baixo, cantos */
231
- .suggestion-box-bottom {
232
- width: 100%;
233
- display: flex;
234
- justify-content: space-between;
235
- margin-top: 10px;
236
- }
237
  """
238
 
239
  # ---------------- Gradio UI ----------------
@@ -242,27 +216,22 @@ with gr.Blocks(css=custom_css, theme="gradio/soft") as demo:
242
  gr.Markdown("### Insira texto administrativo em português:")
243
 
244
  input_text = gr.Textbox(label="", placeholder="Escreva aqui o texto em português...", lines=6)
 
245
  classify_btn = gr.Button("Classificar")
246
  output = gr.HTML()
247
  classify_btn.click(fn=classify_display, inputs=input_text, outputs=output)
248
 
249
  # Sugestões
 
250
  suggestion_display = gr.Textbox(value=suggestions[0], interactive=False, elem_classes="suggestion-text")
251
- prev_btn = gr.Button("", elem_classes="arrow-btn")
252
- next_btn = gr.Button("⟩", elem_classes="arrow-btn")
253
  use_btn = gr.Button("Usar", elem_classes="use-btn")
254
 
255
  prev_btn.click(fn=prev_example, outputs=suggestion_display)
256
  next_btn.click(fn=next_example, outputs=suggestion_display)
257
  use_btn.click(fn=use_suggestion, inputs=suggestion_display, outputs=input_text)
258
 
259
- with gr.Column(elem_classes="suggestion-box"):
260
- gr.Markdown("**Sugestões**", elem_classes="suggestion-box-title")
261
- suggestion_display.render()
262
- with gr.Row(elem_classes="suggestion-box-bottom"):
263
- prev_btn.render()
264
- next_btn.render()
265
- use_btn.render()
266
 
267
  # ---------------- Launch ----------------
268
  if __name__ == "__main__":
 
2
  # -*- coding: utf-8 -*-
3
  """
4
  🪶 Council Matters Classifier – PT
5
+ Dark modern Gradio interface with compact arrow buttons on top of suggestion box.
6
  """
7
 
8
  import gradio as gr
 
170
  chips += f"<span class='output-chip' style='border-color:{color}80;color:{color}'>{label} ({prob:.0%})</span>"
171
  return f"<div style='display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:10px'>{chips}</div>"
172
 
173
+ # ---------------- CSS atualizado ----------------
174
  custom_css = """
175
  body { background-color: #0c0c0c; color: #f1f1f1; font-family: 'Inter', sans-serif; }
176
  .gradio-container { background-color: #0c0c0c; color: #f1f1f1; }
 
179
  button { background-color: #007aff !important; color: white !important; font-weight: 600 !important; border-radius: 8px !important; border: none !important; }
180
  button:hover { background-color: #00aaff !important; }
181
  .output-chip { background-color: #1a1a1a; padding: 5px 12px; border-radius: 8px; font-weight: 500; border: 1px solid #007aff33; }
 
 
182
  .suggestion-box {
183
  background-color: #112f50;
184
  border-radius: 10px;
185
  border: 1px solid #1f3c5a;
186
+ padding: 10px;
 
 
187
  display: flex;
 
188
  align-items: center;
189
+ justify-content: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  color: #eee;
191
+ margin-top: 25px;
192
+ position: relative;
193
  }
 
 
194
  .arrow-btn {
195
  width: 25px;
196
  height: 25px;
 
203
  font-weight: bold;
204
  }
205
  .arrow-btn:hover { color: #ffffff; transform: scale(1.3); }
206
+ .use-btn { background-color:#66b3ff !important; color:#000 !important; font-weight:600 !important; border-radius:6px !important; padding:3px 8px !important; margin-left:5px;}
207
  .use-btn:hover { background-color:#99ccff !important; }
208
+ .suggestion-box .prev-btn { position: absolute; top: 5px; left: 5px; }
209
+ .suggestion-box .next-btn { position: absolute; top: 5px; right: 5px; }
210
+ .suggestion-box .suggestion-text { width: 100%; text-align: center; border:none; background:none; color:#eee; font-weight:500; padding-top:8px; }
 
 
 
 
 
211
  """
212
 
213
  # ---------------- Gradio UI ----------------
 
216
  gr.Markdown("### Insira texto administrativo em português:")
217
 
218
  input_text = gr.Textbox(label="", placeholder="Escreva aqui o texto em português...", lines=6)
219
+
220
  classify_btn = gr.Button("Classificar")
221
  output = gr.HTML()
222
  classify_btn.click(fn=classify_display, inputs=input_text, outputs=output)
223
 
224
  # Sugestões
225
+ prev_btn = gr.Button("⟨", elem_classes="prev-btn arrow-btn")
226
  suggestion_display = gr.Textbox(value=suggestions[0], interactive=False, elem_classes="suggestion-text")
227
+ next_btn = gr.Button("", elem_classes="next-btn arrow-btn")
 
228
  use_btn = gr.Button("Usar", elem_classes="use-btn")
229
 
230
  prev_btn.click(fn=prev_example, outputs=suggestion_display)
231
  next_btn.click(fn=next_example, outputs=suggestion_display)
232
  use_btn.click(fn=use_suggestion, inputs=suggestion_display, outputs=input_text)
233
 
234
+ gr.Row([prev_btn, suggestion_display, next_btn, use_btn], elem_id="suggestion-box")
 
 
 
 
 
 
235
 
236
  # ---------------- Launch ----------------
237
  if __name__ == "__main__":