C2MV commited on
Commit
4f904dd
verified
1 Parent(s): 017603a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -334,12 +334,10 @@ def cargar_ejemplo_od():
334
  df[f"Concentraci贸n Real (OD)"] = valores_reales
335
  return 1.0, "OD", 7, df
336
 
337
- # Funci贸n para actualizar la tabla
338
  def actualizar_tabla_evento(n_filas, concentracion, unidad):
339
  df = generar_tabla(n_filas, concentracion, unidad)
340
  return df
341
 
342
- # Funci贸n para limpiar datos
343
  def limpiar_datos():
344
  df = generar_tabla(7, 2000000, "UFC")
345
  return (
@@ -352,7 +350,6 @@ def limpiar_datos():
352
  "" # Informe Output
353
  )
354
 
355
- # Funci贸n para generar datos sint茅ticos
356
  def generar_datos_sinteticos_evento(df):
357
  df = df.copy()
358
  desviacion_std = 0.05 * df[df.columns[-2]].mean() # 5% de la media como desviaci贸n est谩ndar
@@ -378,7 +375,7 @@ def exportar_word(df, informe_md):
378
  return None
379
 
380
  filename = exportar_informe_word(df_valid, informe_md)
381
- return gr.File.update(value=filename, visible=True)
382
 
383
  def exportar_latex(df, informe_md):
384
  df_valid = df.copy()
@@ -395,7 +392,7 @@ def exportar_latex(df, informe_md):
395
  return None
396
 
397
  filename = exportar_informe_latex(df_valid, informe_md)
398
- return gr.File.update(value=filename, visible=True)
399
 
400
  # Interfaz Gradio
401
  with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
@@ -453,6 +450,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
453
  exportar_word_btn = gr.Button("馃捑 Exportar Informe Word", variant="primary")
454
  exportar_latex_btn = gr.Button("馃捑 Exportar Informe LaTeX", variant="primary")
455
 
 
 
 
 
456
  # Eventos
457
  input_components = [tabla_output]
458
  output_components = [estado_output, graficos_output, informe_output]
@@ -508,24 +509,24 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
508
  outputs=tabla_output
509
  )
510
 
511
- # Evento de copiar informe
512
  copiar_btn.click(
513
  fn=copiar_informe,
514
  inputs=[informe_output],
515
  outputs=[]
516
  )
517
 
518
- # Eventos de exportar informes
519
  exportar_word_btn.click(
520
  fn=exportar_word,
521
  inputs=[tabla_output, informe_output],
522
- outputs=exportar_word_btn
523
  )
524
 
525
  exportar_latex_btn.click(
526
  fn=exportar_latex,
527
  inputs=[tabla_output, informe_output],
528
- outputs=exportar_latex_btn
529
  )
530
 
531
  # Inicializar la interfaz con el ejemplo base
@@ -550,4 +551,5 @@ with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
550
  )
551
 
552
  # Lanzar la interfaz
553
- interfaz.launch()
 
 
334
  df[f"Concentraci贸n Real (OD)"] = valores_reales
335
  return 1.0, "OD", 7, df
336
 
 
337
  def actualizar_tabla_evento(n_filas, concentracion, unidad):
338
  df = generar_tabla(n_filas, concentracion, unidad)
339
  return df
340
 
 
341
  def limpiar_datos():
342
  df = generar_tabla(7, 2000000, "UFC")
343
  return (
 
350
  "" # Informe Output
351
  )
352
 
 
353
  def generar_datos_sinteticos_evento(df):
354
  df = df.copy()
355
  desviacion_std = 0.05 * df[df.columns[-2]].mean() # 5% de la media como desviaci贸n est谩ndar
 
375
  return None
376
 
377
  filename = exportar_informe_word(df_valid, informe_md)
378
+ return filename # Retornar el nombre del archivo
379
 
380
  def exportar_latex(df, informe_md):
381
  df_valid = df.copy()
 
392
  return None
393
 
394
  filename = exportar_informe_latex(df_valid, informe_md)
395
+ return filename # Retornar el nombre del archivo
396
 
397
  # Interfaz Gradio
398
  with gr.Blocks(theme=gr.themes.Soft()) as interfaz:
 
450
  exportar_word_btn = gr.Button("馃捑 Exportar Informe Word", variant="primary")
451
  exportar_latex_btn = gr.Button("馃捑 Exportar Informe LaTeX", variant="primary")
452
 
453
+ # Agregar componentes gr.File para los archivos exportados
454
+ exportar_word_file = gr.File(label="Informe en Word", visible=False)
455
+ exportar_latex_file = gr.File(label="Informe en LaTeX", visible=False)
456
+
457
  # Eventos
458
  input_components = [tabla_output]
459
  output_components = [estado_output, graficos_output, informe_output]
 
509
  outputs=tabla_output
510
  )
511
 
512
+ # Evento de copiar informe (no necesita cambios)
513
  copiar_btn.click(
514
  fn=copiar_informe,
515
  inputs=[informe_output],
516
  outputs=[]
517
  )
518
 
519
+ # Eventos de exportar informes (ajustados)
520
  exportar_word_btn.click(
521
  fn=exportar_word,
522
  inputs=[tabla_output, informe_output],
523
+ outputs=exportar_word_file # Output al componente gr.File
524
  )
525
 
526
  exportar_latex_btn.click(
527
  fn=exportar_latex,
528
  inputs=[tabla_output, informe_output],
529
+ outputs=exportar_latex_file # Output al componente gr.File
530
  )
531
 
532
  # Inicializar la interfaz con el ejemplo base
 
551
  )
552
 
553
  # Lanzar la interfaz
554
+ if __name__ == "__main__":
555
+ interfaz.launch()