36 lines
1.5 KiB
Python
36 lines
1.5 KiB
Python
import tkinter as tk
|
|
|
|
class FrameInicio(tk.Frame):
|
|
def __init__(self, master=None, bd=None):
|
|
super().__init__(master, bg="#1e1e1e")
|
|
self.bd = bd
|
|
self._atualizar_dados()
|
|
self._criar_layout()
|
|
|
|
def _atualizar_dados(self):
|
|
"""Busca os totais do banco de dados e prepara os dados para exibição."""
|
|
total_pessoas = len(self.bd.pessoas.listar_todos()) if self.bd else 0
|
|
total_pets = len(self.bd.pets.listar_todos()) if self.bd else 0
|
|
total_adocoes = len(self.bd.adocoes.listar_todos()) if self.bd else 0
|
|
|
|
self.caixas_info = [
|
|
{"titulo": "Pessoas", "quantidade": total_pessoas, "cor": "#ff9966"},
|
|
{"titulo": "Pets", "quantidade": total_pets, "cor": "#66c2ff"},
|
|
{"titulo": "Adoções", "quantidade": total_adocoes, "cor": "#99e699"},
|
|
]
|
|
|
|
def _criar_layout(self):
|
|
container = tk.Frame(self, bg="#1e1e1e")
|
|
container.pack(pady=40, padx=50, fill="x")
|
|
|
|
for caixa in self.caixas_info:
|
|
frame = tk.Frame(container, bg=caixa["cor"], width=200, height=120)
|
|
frame.pack(side="left", expand=True, padx=10, pady=10, fill="both")
|
|
|
|
titulo = tk.Label(frame, text=caixa["titulo"], font=("Arial", 16, "bold"), bg=caixa["cor"], fg="white")
|
|
titulo.pack(pady=(20, 5))
|
|
|
|
valor = tk.Label(frame, text=str(caixa["quantidade"]), font=("Arial", 24), bg=caixa["cor"], fg="white")
|
|
valor.pack()
|
|
|
|
|