from tkinter import *
root = Tk()
root.geometry("1000x600")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Património Líquido")
titulo = Label(root, text="Património Líquido",
font=("Arial", 30, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.30, rely=0.05)
Label(root, text="Ativo", font=("Arial", 18, "bold"),
bg="#103030", fg="#49e3e3").place(relx=0.05, rely=0.15)
Label(root, text="Passivo", font=("Arial", 18, "bold"),
bg="#103030", fg="#49e3e3").place(relx=0.55, rely=0.15)
Label(root, text="Valor dos imóveis:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.05, rely=0.25)
valor_imoveis = StringVar()
Entry(root, textvariable=valor_imoveis, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.25, rely=0.25, relwidth=0.2)
Label(root, text="Valor dos carros:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.05, rely=0.35)
valor_carros = StringVar()
Entry(root, textvariable=valor_carros, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.25, rely=0.35, relwidth=0.2)
Label(root, text="Investimentos/Poupanças:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.05, rely=0.45)
investimentos = StringVar()
Entry(root, textvariable=investimentos, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.3, rely=0.45, relwidth=0.2)
Label(root, text="Outros ativos:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.05, rely=0.55)
outros_ativos = StringVar()
Entry(root, textvariable=outros_ativos, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.25, rely=0.55, relwidth=0.2)
Label(root, text="Dívidas de imóveis:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.55, rely=0.25)
divida_imoveis = StringVar()
Entry(root, textvariable=divida_imoveis, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.75, rely=0.25, relwidth=0.2)
Label(root, text="Dívidas de carros:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.55, rely=0.35)
divida_carros = StringVar()
Entry(root, textvariable=divida_carros, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.75, rely=0.35, relwidth=0.2)
Label(root, text="Outras dívidas:", font=("Arial", 14),
bg="#103030", fg="white").place(relx=0.55, rely=0.45)
outras_dividas = StringVar()
Entry(root, textvariable=outras_dividas, font=("Arial", 12),
bg="white", fg="black", justify='center').place(relx=0.75, rely=0.45, relwidth=0.2)
def calcular_patrimonio():
try:
ativo_total = (float(valor_imoveis.get() or 0) +
float(valor_carros.get() or 0) +
float(investimentos.get() or 0) +
float(outros_ativos.get() or 0))
passivo_total = (float(divida_imoveis.get() or 0) +
float(divida_carros.get() or 0) +
float(outras_dividas.get() or 0))
patrimonio_liquido = ativo_total - passivo_total
resultado_label.config(text=f"Património Líquido: € {patrimonio_liquido:,.2f}", fg="yellow")
except ValueError:
resultado_label.config(text="Erro: Verifique os valores inseridos", fg="red")
def limpar():
valor_imoveis.set("")
valor_carros.set("")
investimentos.set("")
outros_ativos.set("")
divida_imoveis.set("")
divida_carros.set("")
outras_dividas.set("")
resultado_label.config(text="")
botao_calcular = Button(root, text="Calcular", font=("Arial", 14, "bold"),
bg="#49e3e3", fg="black", command=calcular_patrimonio)
botao_calcular.place(relx=0.35, rely=0.65, relwidth=0.15)
botao_limpar = Button(root, text="Limpar", font=("Arial", 14, "bold"),
bg="red", fg="white", command=limpar)
botao_limpar.place(relx=0.55, rely=0.65, relwidth=0.15)
resultado_label = Label(root, text="", font=("Arial", 18, "bold"),
bg="#103030", fg="yellow")
resultado_label.place(relx=0.35, rely=0.75)
root.mainloop()
Comentários
Enviar um comentário