112 lines
3.3 KiB
Python
112 lines
3.3 KiB
Python
|
import tkinter as tk
|
||
|
from tkinter import ttk
|
||
|
from tkinter import messagebox
|
||
|
import funciones_comunes as fc
|
||
|
import x1_importar_to_master
|
||
|
import x2_master_export2translate
|
||
|
import x3_llm_auto_translate
|
||
|
import x4_integrate_translates_to_master
|
||
|
import x5_complete_empty_cells_master
|
||
|
import x6_update_from_master
|
||
|
|
||
|
# Crear la ventana principal
|
||
|
ventana = tk.Tk()
|
||
|
ventana.title("Ayuda para traducir textos de TIA Portal")
|
||
|
ventana.geometry("600x400")
|
||
|
|
||
|
|
||
|
# Funciones que se llamarán cuando se presionen los botones
|
||
|
def accion_boton1():
|
||
|
print("Ejecutando x1_importar_to_master.py")
|
||
|
x1_importar_to_master.run()
|
||
|
|
||
|
def accion_boton2():
|
||
|
indice_seleccionado = combo.current()
|
||
|
x2_master_export2translate.run(indice_seleccionado)
|
||
|
|
||
|
def accion_boton3():
|
||
|
indice_seleccionado = combo.current()
|
||
|
traducir_todo = messagebox.askyesno("Traducir todo", "¿Desea traducir todas las celdas (s/n)? ")
|
||
|
|
||
|
x3_llm_auto_translate.run(indice_seleccionado, traducir_todo)
|
||
|
|
||
|
def accion_boton4():
|
||
|
indice_seleccionado = combo.current()
|
||
|
x4_integrate_translates_to_master.run(indice_seleccionado, 0.5)
|
||
|
|
||
|
def accion_boton5():
|
||
|
indice_seleccionado = combo.current()
|
||
|
indice_seleccionado2 = combo2.current()
|
||
|
x5_complete_empty_cells_master.run(indice_seleccionado, indice_seleccionado2)
|
||
|
|
||
|
def accion_boton6():
|
||
|
indice_seleccionado = combo.current()
|
||
|
x6_update_from_master.run(indice_seleccionado)
|
||
|
|
||
|
|
||
|
# Crear los botones con el mismo ancho
|
||
|
button_width = 70
|
||
|
paso1 = tk.Button(ventana, text="1 - Importar al Master", command=accion_boton1, width=button_width)
|
||
|
paso2 = tk.Button(
|
||
|
ventana,
|
||
|
text="2 - Exportar Idioma a 2_master_export2translate.xlsx.",
|
||
|
command=accion_boton2,
|
||
|
width=button_width
|
||
|
)
|
||
|
paso3 = tk.Button(
|
||
|
ventana,
|
||
|
text="3 - Traducir y generar 3_master_export2translate_translated.xlsx.",
|
||
|
command=accion_boton3,
|
||
|
width=button_width
|
||
|
)
|
||
|
paso4 = tk.Button(
|
||
|
ventana,
|
||
|
text="4- Integrar las traducciones al 1_hmi_master_translates.",
|
||
|
command=accion_boton4,
|
||
|
width=button_width
|
||
|
)
|
||
|
paso5 = tk.Button(
|
||
|
ventana,
|
||
|
text="5 - Completar en 1_hmi_master_translates el idioma seleccionado usando el segundo idioma.",
|
||
|
command=accion_boton5,
|
||
|
width=button_width
|
||
|
)
|
||
|
paso6 = tk.Button(
|
||
|
ventana,
|
||
|
text="6 - Exportar usando un archivo exporta desde Tia Portal usando 1_hmi_master_translates.",
|
||
|
command=accion_boton6,
|
||
|
width=button_width
|
||
|
)
|
||
|
|
||
|
# Crear una variable para almacenar el idioma seleccionado
|
||
|
idioma_var = tk.StringVar()
|
||
|
idioma_var2 = tk.StringVar()
|
||
|
# Crear un combobox (OptionMenu) para seleccionar el idioma
|
||
|
combo = ttk.Combobox(ventana, textvariable=idioma_var, state="readonly")
|
||
|
combo2 = ttk.Combobox(ventana, textvariable=idioma_var2, state="readonly")
|
||
|
label1 = tk.Label(ventana, text="Idioma de Traduccion:")
|
||
|
label2 = tk.Label(ventana, text="Selecciona segundo idioma:")
|
||
|
|
||
|
# Rellenar el combobox con los nombres de los idiomas
|
||
|
combo["values"] = [nombre for _, (nombre, _) in fc.IDIOMAS.items()]
|
||
|
combo2["values"] = [nombre for _, (nombre, _) in fc.IDIOMAS.items()]
|
||
|
|
||
|
# Ubicar el combobox en la ventana
|
||
|
label1.pack(pady=1)
|
||
|
combo.pack(pady=1)
|
||
|
label2.pack(pady=1)
|
||
|
combo2.pack(pady=1)
|
||
|
paso1.pack(pady=(30,2))
|
||
|
paso2.pack(pady=2)
|
||
|
paso3.pack(pady=2)
|
||
|
paso4.pack(pady=2)
|
||
|
paso5.pack(pady=2)
|
||
|
paso6.pack(pady=2)
|
||
|
|
||
|
# Seleccionar el primer elemento por defecto
|
||
|
combo.current(4)
|
||
|
combo2.current(1)
|
||
|
|
||
|
# Iniciar el bucle principal de la interfaz
|
||
|
ventana.mainloop()
|