From e330ab548cbc85ca6b35f047bf34d16c4d5f1e3c Mon Sep 17 00:00:00 2001 From: Emersonjsc Date: Tue, 24 Jun 2025 10:54:42 -0300 Subject: [PATCH] Home page --- main.py | 7 +- visao/interface_gui.py | 179 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 163 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index b633b55..c05ec55 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,6 @@ from visao.interface_texto import InterfaceTexto -# from visao.interface_gui import interfaceGUI - +from visao.interface_gui import InterfaceGUI if __name__ == "__main__": - interface = InterfaceTexto() - interface.executar() + app = InterfaceGUI() + app.mainloop() diff --git a/visao/interface_gui.py b/visao/interface_gui.py index cdff20d..965e45e 100644 --- a/visao/interface_gui.py +++ b/visao/interface_gui.py @@ -1,24 +1,165 @@ -import tkinter as tk +import tkinter as tk +from tkinter import font as tkfont +from tkinter import messagebox # Usado para os botões de exemplo -class interfaceGUI: +class InterfaceGUI(tk.Tk): + """Classe principal que gerencia a janela e os frames (painéis).""" + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) - def __init__(self): - # self.bd = BancoDeDados() - self.proximo_id = 1 - self.root = tk.Tk() - self.root.title("Minha Janela") - self.root.geometry("300x200") - - - self.root.configure(bg="#1e1e1e") # fundo escuro - label = tk.Label(self.root, text="Texto", bg="#1e1e1e", fg="white") - botao = tk.Button(self.root, text="OK", bg="#333333", fg="white") + self.title("Sistema de Adoção de Pets") + # Um pouco maior para acomodar melhor o design + self.geometry("1024x600") + self.minsize(900, 550) # Define um tamanho mínimo + self.configure(bg="#1e1e1e") + + # Define fontes para serem usadas na aplicação + self.title_font = tkfont.Font(family='Helvetica', size=16, weight="bold") + self.label_font = tkfont.Font(family='Helvetica', size=10) + self.button_font = tkfont.Font(family='Helvetica', size=20, weight="bold") + self.widget_title_font = tkfont.Font(family='Helvetica', size=12, weight="bold") + + # Container principal que usa todo o espaço + container = tk.Frame(self, bg="#1e1e1e") + container.pack(side="top", fill="both", expand=True) + container.grid_rowconfigure(0, weight=1) + container.grid_columnconfigure(0, weight=1) + + self.frames = {} + # Adicione futuras classes de painel aqui + for F in (HomePage,): + page_name = F.__name__ + frame = F(parent=container, controller=self) + self.frames[page_name] = frame + frame.grid(row=0, column=0, sticky="nsew") + + self.show_frame("HomePage") + + def show_frame(self, page_name): + """Mostra um frame para a página requisitada.""" + frame = self.frames[page_name] + frame.tkraise() + +class ActionCard(tk.Frame): + """Um widget 'Card' reutilizável para as ações principais.""" + def __init__(self, parent, controller, title, description, command): + super().__init__(parent, bg="#2d2d2d", relief="raised", borderwidth=1) + + # Adiciona um padding interno ao card + self.grid_propagate(False) # Impede que os widgets filhos redimensionem o card + self.config(width=250, height=180) # Tamanho fixo para o card + + title_label = tk.Label( + self, + text=title, + font=controller.widget_title_font, + fg="white", + bg="#2d2d2d" + ) + title_label.pack(pady=(15, 5)) + + desc_label = tk.Label( + self, + text=description, + font=controller.label_font, + fg="#cccccc", # Um cinza mais claro + bg="#2d2d2d" + ) + desc_label.pack(pady=5) + + # Botão de ação estilizado como um ícone + action_button = tk.Button( + self, + text="➕", # Um ícone de 'mais' simples. Você pode usar uma imagem aqui. + font=controller.button_font, + fg="white", + bg="#4a4a4a", + activebackground="#6a6a6a", + activeforeground="white", + relief="flat", + width=3, + command=command + ) + action_button.pack(side="bottom", pady=15) + +class HomePage(tk.Frame): + """Painel da tela inicial (Home), agora com o layout de cards.""" + def __init__(self, parent, controller): + super().__init__(parent, bg="#1e1e1e") + self.controller = controller + + # Configura o grid principal da HomePage para ter 2 colunas + self.grid_columnconfigure(0, weight=2) # Coluna da esquerda (cards) + self.grid_columnconfigure(1, weight=1) # Coluna da direita (configurações) + self.grid_rowconfigure(0, weight=1) + + # --- Frame da Esquerda para os ActionCards --- + left_frame = tk.Frame(self, bg="#1e1e1e") + left_frame.grid(row=0, column=0, sticky="nsew", padx=20, pady=20) - def executar(self): - self.janela_principal(); + # Configura um grid dentro do frame da esquerda para os cards + left_frame.grid_columnconfigure((0, 1), weight=1) + left_frame.grid_rowconfigure((0, 1), weight=1) + + # --- Frame da Direita para Controles e Botão --- + right_frame = tk.Frame(self, bg="#1e1e1e") + right_frame.grid(row=0, column=1, sticky="nsew", padx=20, pady=20) + right_frame.grid_columnconfigure(0, weight=1) + # As rows do frame da direita não precisam expandir, então não configuramos rowconfigure - def janela_principal(self): - self.root.mainloop() + # --- Criando e posicionando os CARDS --- + # Exemplo de comandos. Troque isso pelas suas funções reais. + cmd_pets = lambda: messagebox.showinfo("Ação", "Abrir gerenciamento de Pets") + cmd_pessoas = lambda: messagebox.showinfo("Ação", "Abrir gerenciamento de Pessoas") + cmd_adocoes = lambda: messagebox.showinfo("Ação", "Abrir tela para nova adoção") + cmd_historico = lambda: messagebox.showinfo("Ação", "Abrir histórico de adoções") -app = interfaceGUI() -app.executar() \ No newline at end of file + card1 = ActionCard(left_frame, controller, "Gerenciar Pets", "Adicionar, editar e remover pets", cmd_pets) + card1.grid(row=0, column=0, padx=10, pady=10, sticky="nsew") + + card2 = ActionCard(left_frame, controller, "Gerenciar Pessoas", "Cadastrar adotantes e doadores", cmd_pessoas) + card2.grid(row=0, column=1, padx=10, pady=10, sticky="nsew") + + card3 = ActionCard(left_frame, controller, "Realizar Adoção", "Iniciar um novo processo de adoção", cmd_adocoes) + card3.grid(row=1, column=0, padx=10, pady=10, sticky="nsew") + + card4 = ActionCard(left_frame, controller, "Histórico", "Consultar adoções realizadas", cmd_historico) + card4.grid(row=1, column=1, padx=10, pady=10, sticky="nsew") + + # --- Criando os widgets no FRAME DA DIREITA --- + + # Frame para "Configurações" + settings_frame = tk.LabelFrame( + right_frame, + text="Configurações Gerais", + font=controller.title_font, + bg="#2d2d2d", + fg="white", + padx=15, + pady=15 + ) + settings_frame.pack(fill="x", expand=False, pady=(0, 20)) # pady adiciona espaço abaixo + + tk.Label(settings_frame, text="Nome do Relatório:", font=controller.label_font, bg="#2d2d2d", fg="white").pack(anchor="w") + tk.Entry(settings_frame, bg="#4a4a4a", fg="white", insertbackground="white", relief="flat").pack(fill="x", pady=(2, 10)) + + tk.Label(settings_frame, text="Salvar em:", font=controller.label_font, bg="#2d2d2d", fg="white").pack(anchor="w") + tk.Entry(settings_frame, bg="#4a4a4a", fg="white", insertbackground="white", relief="flat").pack(fill="x", pady=(2, 10)) + + # Botão START + start_button = tk.Button( + right_frame, + text="INICIAR", + font=controller.title_font, + bg="#6be2e8", # Azul-ciano da imagem + fg="#1e1e1e", # Texto escuro para contraste + activebackground="#88f0f8", + relief="flat", + pady=10 + ) + start_button.pack(fill="x", side="bottom") + + +if __name__ == "__main__": + app = InterfaceGUI() + app.mainloop() \ No newline at end of file