from tkinter import *
root = Tk()
root.geometry("500x400")
root.resizable(0, 0)
root.config(bg="#02407d")
root.title("Custo Total do Trabalhador")
titulo = Label(text="Custo Total do Trabalhador",
font=("Arial", "20", "bold"),bg="#02407d",fg="#14f5ed")
titulo.place(relx=0.05, rely=0.05)
texto_sub1 = Label(text="Salário Base:",
font=("Arial", "15", "bold"),bg="#02407d",fg="#14f5ed")
texto_sub1.place(relx=0.15, rely=0.25)
texto_sub2 = Label(text="Outros Custos:",
font=("Arial", "15", "bold"),bg="#02407d",fg="#14f5ed")
texto_sub2.place(relx=0.1, rely=0.45)
Salário_Base = DoubleVar()
Salário_Base_entrada = Entry(textvariable=Salário_Base,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Salário_Base_entrada.place(relx=0.55, rely=0.25, relwidth=0.25)
Outros_Custos = DoubleVar()
Outros_Custos_entrada = Entry(textvariable=Outros_Custos,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Outros_Custos_entrada.place(relx=0.55, rely=0.45, relwidth=0.25)
def app():
outros = Outros_Custos.get()
salario = Salário_Base.get()
encargos_sociais = 0.30 * salario
beneficios = 0.10 * salario
impostos = 0.15 * salario
custo_total = salario + encargos_sociais + beneficios + impostos + outros
mensagem = f"O custo total do trabalhador é de {round(custo_total,2)} € por mês."
resultado.set(mensagem)
def limpar():
Outros_Custos_entrada.delete(0, END)
Salário_Base_entrada.delete(0, END)
resultado.set("")
#
but1 = Button(text="Verificar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.05, rely=0.65, relwidth=0.25, relheight=0.1)
but_limpar = Button(text="Limpar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=limpar)
but_limpar.place(relx=0.35, rely=0.65, relwidth=0.25, relheight=0.1)
but_sair = Button(text="Sair", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=root.destroy)
but_sair.place(relx=0.65, rely=0.65, relwidth=0.25, relheight=0.1)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9,relheight=0.15)
root.mainloop()