pets/visao/interface_gui.py

165 lines
6.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import tkinter as tk
from tkinter import font as tkfont
from tkinter import messagebox # Usado para os botões de exemplo
class InterfaceGUI(tk.Tk):
"""Classe principal que gerencia a janela e os frames (painéis)."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
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)
# 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
# --- 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")
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()