DHEIVER commited on
Commit
125fe7d
·
verified ·
1 Parent(s): 12f8193

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -50
app.py CHANGED
@@ -423,20 +423,10 @@ THEME = gr.themes.Soft(
423
  block_title_text_size="xl",
424
  )
425
 
426
- def update_progress(progress, total_questions=5):
427
- """Atualiza a barra de progresso."""
428
  answered = sum(1 for p in progress if p is not None)
429
- return f"{answered}/{total_questions} questões respondidas", answered / total_questions
430
-
431
- def reset_interface():
432
- """Reinicia a interface para um novo teste."""
433
- return [None] * 5 + [
434
- gr.update(visible=False),
435
- gr.update(interactive=True),
436
- None, None, None, None,
437
- "0/5 questões respondidas",
438
- 0
439
- ]
440
 
441
  def create_interface():
442
  """Cria interface moderna do Gradio."""
@@ -460,10 +450,8 @@ def create_interface():
460
 
461
  # Container principal
462
  with gr.Column(elem_classes="container"):
463
- # Barra de progresso
464
- with gr.Row(elem_classes="progress-bar"):
465
- progress_text = gr.Markdown("0/5 questões respondidas")
466
- progress_bar = gr.Progress()
467
 
468
  # Questões
469
  radio_components = []
@@ -473,22 +461,18 @@ def create_interface():
473
  radio = gr.Radio(
474
  choices=[f"{perfil} - {desc}" for perfil, desc in questao['opcoes']],
475
  label="Selecione a opção mais adequada:",
476
- scale=0,
477
  interactive=True
478
  )
479
  radio_components.append(radio)
480
 
481
  # Botão de análise
482
- with gr.Row(elem_classes="center"):
483
- analyze_btn = gr.Button(
484
- "📊 Analisar Perfil",
485
- variant="primary",
486
- scale=0,
487
- min_width=200
488
- )
489
 
490
  # Área de resultados
491
- with gr.Group(visible=False, elem_classes="result-card") as result_box:
492
  gr.Markdown("## 📊 Resultado da Análise")
493
 
494
  with gr.Row():
@@ -497,18 +481,17 @@ def create_interface():
497
 
498
  # Métricas principais
499
  with gr.Column():
500
- with gr.Group():
501
- gr.Markdown("### Perfis Principais")
502
- perfil_dominante = gr.Textbox(
503
- label="Perfil Dominante",
504
- show_label=True,
505
- interactive=False
506
- )
507
- perfil_secundario = gr.Textbox(
508
- label="Perfil Secundário",
509
- show_label=True,
510
- interactive=False
511
- )
512
 
513
  # Relatório detalhado
514
  gr.Markdown("### 📝 Relatório Detalhado")
@@ -516,30 +499,23 @@ def create_interface():
516
 
517
  # Botões de ação
518
  with gr.Row():
519
- download_btn = gr.Button("⬇️ Baixar Relatório PDF", variant="secondary")
520
  reset_btn = gr.Button("🔄 Fazer Novo Teste", variant="secondary")
521
  share_btn = gr.Button("📤 Compartilhar Resultado", variant="secondary")
522
 
523
  # Footer
524
- with gr.Row(elem_classes="footer"):
525
  gr.Markdown("""
526
  💡 **Observação:** Este é um teste comportamental indicativo.
527
- Os resultados representam tendências naturais de comportamento,
528
- que podem variar dependendo do contexto e situação.
529
  """)
530
 
531
  # Event handlers
532
  def process_and_visualize(*answers):
533
  """Processa respostas e gera visualizações."""
534
  percentuais = calcular_perfil(answers)
535
-
536
- # Criar gráfico
537
  fig = create_disc_plot(percentuais)
538
-
539
- # Gerar relatório
540
  report = gerar_relatorio_personalizado(percentuais)
541
 
542
- # Identificar perfis principais
543
  sorted_profiles = dict(sorted(percentuais.items(), key=lambda x: x[1], reverse=True))
544
  main_profile = list(sorted_profiles.keys())[0]
545
  secondary_profile = list(sorted_profiles.keys())[1]
@@ -563,12 +539,21 @@ def create_interface():
563
  analyze_btn: gr.update(interactive=True)
564
  }
565
 
 
 
 
 
 
 
 
 
 
566
  # Event bindings
567
  for radio in radio_components:
568
  radio.change(
569
  lambda *args: update_progress(args),
570
  inputs=radio_components,
571
- outputs=[progress_text, progress_bar]
572
  )
573
  radio.change(
574
  update_display,
@@ -591,8 +576,7 @@ def create_interface():
591
  perfil_dominante,
592
  perfil_secundario,
593
  output,
594
- progress_text,
595
- progress_bar
596
  ]
597
  )
598
 
 
423
  block_title_text_size="xl",
424
  )
425
 
426
+ def update_progress(progress):
427
+ """Atualiza o texto de progresso."""
428
  answered = sum(1 for p in progress if p is not None)
429
+ return f"{answered}/5 questões respondidas"
 
 
 
 
 
 
 
 
 
 
430
 
431
  def create_interface():
432
  """Cria interface moderna do Gradio."""
 
450
 
451
  # Container principal
452
  with gr.Column(elem_classes="container"):
453
+ # Indicador de progresso
454
+ progress_text = gr.Markdown("0/5 questões respondidas")
 
 
455
 
456
  # Questões
457
  radio_components = []
 
461
  radio = gr.Radio(
462
  choices=[f"{perfil} - {desc}" for perfil, desc in questao['opcoes']],
463
  label="Selecione a opção mais adequada:",
 
464
  interactive=True
465
  )
466
  radio_components.append(radio)
467
 
468
  # Botão de análise
469
+ analyze_btn = gr.Button(
470
+ "📊 Analisar Perfil",
471
+ variant="primary"
472
+ )
 
 
 
473
 
474
  # Área de resultados
475
+ with gr.Group(visible=False) as result_box:
476
  gr.Markdown("## 📊 Resultado da Análise")
477
 
478
  with gr.Row():
 
481
 
482
  # Métricas principais
483
  with gr.Column():
484
+ gr.Markdown("### Perfis Principais")
485
+ perfil_dominante = gr.Textbox(
486
+ label="Perfil Dominante",
487
+ show_label=True,
488
+ interactive=False
489
+ )
490
+ perfil_secundario = gr.Textbox(
491
+ label="Perfil Secundário",
492
+ show_label=True,
493
+ interactive=False
494
+ )
 
495
 
496
  # Relatório detalhado
497
  gr.Markdown("### 📝 Relatório Detalhado")
 
499
 
500
  # Botões de ação
501
  with gr.Row():
 
502
  reset_btn = gr.Button("🔄 Fazer Novo Teste", variant="secondary")
503
  share_btn = gr.Button("📤 Compartilhar Resultado", variant="secondary")
504
 
505
  # Footer
506
+ with gr.Row():
507
  gr.Markdown("""
508
  💡 **Observação:** Este é um teste comportamental indicativo.
509
+ Os resultados representam tendências naturais de comportamento.
 
510
  """)
511
 
512
  # Event handlers
513
  def process_and_visualize(*answers):
514
  """Processa respostas e gera visualizações."""
515
  percentuais = calcular_perfil(answers)
 
 
516
  fig = create_disc_plot(percentuais)
 
 
517
  report = gerar_relatorio_personalizado(percentuais)
518
 
 
519
  sorted_profiles = dict(sorted(percentuais.items(), key=lambda x: x[1], reverse=True))
520
  main_profile = list(sorted_profiles.keys())[0]
521
  secondary_profile = list(sorted_profiles.keys())[1]
 
539
  analyze_btn: gr.update(interactive=True)
540
  }
541
 
542
+ def reset_interface():
543
+ """Reinicia a interface para um novo teste."""
544
+ return [None] * len(radio_components) + [
545
+ gr.update(visible=False),
546
+ gr.update(interactive=True),
547
+ None, None, None, None,
548
+ "0/5 questões respondidas"
549
+ ]
550
+
551
  # Event bindings
552
  for radio in radio_components:
553
  radio.change(
554
  lambda *args: update_progress(args),
555
  inputs=radio_components,
556
+ outputs=progress_text
557
  )
558
  radio.change(
559
  update_display,
 
576
  perfil_dominante,
577
  perfil_secundario,
578
  output,
579
+ progress_text
 
580
  ]
581
  )
582