Repository navigation
Expand file tree
/
Copy pathfrontend.py
More file actions
79 lines (66 loc) · 2.4 KB
/
Copy pathfrontend.py
File metadata and controls
79 lines (66 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#Front-end (GUI)
import customtkinter as ctk
from tkinter import filedialog, messagebox
from backend import processar_enriquecimento
#Apparence
ctk.set_appearance_mode("Dark")
class Aplicacao(ctk.CTk):
def __init__(self):
super().__init__()
self.title("Aplicação de Enriquecimento")
self.geometry("500x250")
self.resizable(False, False)
self.arquivo_path = ctk.StringVar()
self._criar_widgets()
def _criar_widgets(self):
# Espaço superior
ctk.CTkLabel(
self,
text="Selecione o arquivo Excel:",
text_color="white",
).pack(pady=(30, 6))
frame = ctk.CTkFrame(self)
frame.pack()
self.entry_arquivo = ctk.CTkEntry(
frame, width=320, textvariable=self.arquivo_path, state="disabled"
)
self.entry_arquivo.pack(side="left", padx=(0, 8))
ctk.CTkButton(
frame,
text="Selecionar arquivo",
corner_radius=20,
command=self._selecionar_arquivo,
).pack(side="left")
self.botao_enriquecer = ctk.CTkButton(
self,
text="Enriquecer",
corner_radius=20,
state="disabled",
command=self._enriquecer,
width=140,
)
self.botao_enriquecer.pack(pady=24)
def _selecionar_arquivo(self):
arquivo = filedialog.askopenfilename(
title="Selecione o Excel",
filetypes=[("Arquivos Excel", "*.xlsx")],
)
if arquivo:
self.arquivo_path.set(arquivo)
self.entry_arquivo.configure(state="normal")
self.entry_arquivo.delete(0, ctk.END)
self.entry_arquivo.insert(0, arquivo)
self.entry_arquivo.configure(state="disabled")
self.botao_enriquecer.configure(state="normal")
def _enriquecer(self):
self.botao_enriquecer.configure(state="disabled")
resultado = processar_enriquecimento(self.arquivo_path.get())
messagebox.showinfo("Resultado", resultado)
# Reset visual
self.arquivo_path.set("")
self.entry_arquivo.configure(state="normal")
self.entry_arquivo.delete(0, ctk.END)
self.entry_arquivo.configure(state="disabled")
if __name__ == "__main__":
app = Aplicacao()
app.mainloop()