VICON: Sistema de Visión configurable V1.0
Trabajo Fin de Master Carlos Manuel Gomez Jimenez
Loading...
Searching...
No Matches
SVGConverterApp Class Reference

Public Member Functions

Public Attributes

Detailed Description

Definition at line 6 of file convertidor_svg2pdf.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
root )

Definition at line 7 of file convertidor_svg2pdf.py.

7 def __init__(self, root):
8 self.root = root
9 self.root.title("Inkscape SVG to PDF Converter")
10 self.root.geometry("500x300")
11 self.root.configure(bg="#f0f0f0")
12
13 self.selected_files = []
14
15 # Interfaz
16 self.label = tk.Label(root, text="Convertidor de SVG a PDF", font=("Arial", 16, "bold"), bg="#f0f0f0")
17 self.label.pack(pady=20)
18
19 self.btn_select = tk.Button(root, text="Seleccionar archivos SVG", command=self.select_files, width=25, bg="#007acc", fg="white")
20 self.btn_select.pack(pady=10)
21
22 self.files_label = tk.Label(root, text="No hay archivos seleccionados", bg="#f0f0f0", fg="#555")
23 self.files_label.pack()
24
25 self.btn_convert = tk.Button(root, text="Convertir a PDF", command=self.convert_files, width=25, bg="#28a745", fg="white", state="disabled")
26 self.btn_convert.pack(pady=20)
27

Member Function/Procedure/Process Documentation

◆ convert_files()

convert_files ( self)

Definition at line 35 of file convertidor_svg2pdf.py.

35 def convert_files(self):
36 output_dir = filedialog.askdirectory(title="Selecciona carpeta de destino")
37 if not output_dir:
38 return
39
40 success_count = 0
41 for svg_path in self.selected_files:
42 file_name = os.path.splitext(os.path.basename(svg_path))[0]
43 pdf_path = os.path.join(output_dir, f"{file_name}.pdf")
44
45 # Comando de Inkscape para exportar
46 # Usamos la sintaxis moderna de Inkscape 1.x
47 command = [
48 "inkscape",
49 svg_path,
50 "--export-type=pdf",
51 f"--export-filename={pdf_path}"
52 ]
53
54 try:
55 # Ejecutamos en segundo plano sin abrir ventana de consola
56 subprocess.run(command, check=True, creationflags=subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0)
57 success_count += 1
58 except Exception as e:
59 messagebox.showerror("Error", f"No se pudo convertir {file_name}: {str(e)}")
60
61 messagebox.showinfo("Proceso terminado", f"Se han convertido {success_count} archivos con éxito.")
62 self.reset_ui()
63

◆ reset_ui()

reset_ui ( self)

Definition at line 64 of file convertidor_svg2pdf.py.

64 def reset_ui(self):
65 self.selected_files = []
66 self.files_label.config(text="No hay archivos seleccionados")
67 self.btn_convert.config(state="disabled")
68

◆ select_files()

select_files ( self)

Definition at line 28 of file convertidor_svg2pdf.py.

28 def select_files(self):
29 files = filedialog.askopenfilenames(title="Selecciona archivos SVG", filetypes=[("Archivos SVG", "*.svg")])
30 if files:
31 self.selected_files = list(files)
32 self.files_label.config(text=f"{len(self.selected_files)} archivos listos.")
33 self.btn_convert.config(state="normal")
34

Member Data Documentation

◆ btn_convert

btn_convert = tk.Button(root, text="Convertir a PDF", command=self.convert_files, width=25, bg="#28a745", fg="white", state="disabled")

Definition at line 25 of file convertidor_svg2pdf.py.

◆ btn_select

btn_select = tk.Button(root, text="Seleccionar archivos SVG", command=self.select_files, width=25, bg="#007acc", fg="white")

Definition at line 19 of file convertidor_svg2pdf.py.

◆ files_label

files_label = tk.Label(root, text="No hay archivos seleccionados", bg="#f0f0f0", fg="#555")

Definition at line 22 of file convertidor_svg2pdf.py.

◆ label

label = tk.Label(root, text="Convertidor de SVG a PDF", font=("Arial", 16, "bold"), bg="#f0f0f0")

Definition at line 16 of file convertidor_svg2pdf.py.

◆ root

root = root

Definition at line 8 of file convertidor_svg2pdf.py.

◆ selected_files [1/2]

list selected_files = []

Definition at line 13 of file convertidor_svg2pdf.py.

◆ selected_files [2/2]

str selected_files = f"{len(self.selected_files)} archivos listos.")

Definition at line 31 of file convertidor_svg2pdf.py.


The documentation for this design unit was generated from the following file: