from tkinter import *
root = Tk()
root.geometry("800x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Rentabilidade sobre o Investimento em Anúncios")
titulo = Label(text="Rentabilidade sobre o Investimento em Anúncios",
font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.03, rely=0.05)
texto_sub1 = Label(text="Receita gerada pelos anúncios:",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.08, rely=0.25)
texto_sub2 = Label(text="Custo Total dos anúncios :",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.15, rely=0.45)
Receita_gerada_anúncios = StringVar()
Receita_gerada_anúncios_entrada = Entry(textvariable=Receita_gerada_anúncios,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Receita_gerada_anúncios_entrada.place(relx=0.62, rely=0.26, relwidth=0.35)
Custo_Total_anúncios = StringVar()
Custo_Total_anúncios_entrada = Entry(textvariable=Custo_Total_anúncios,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Custo_Total_anúncios_entrada.place(relx=0.62, rely=0.46, relwidth=0.35)
def limpar():
Custo_Total_anúncios_entrada.delete(0, END)
Receita_gerada_anúncios_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
try:
custo = float(Custo_Total_anúncios.get())
receita = float(Receita_gerada_anúncios.get())
if custo == 0:
mensagem = "O custo do anúncio não pode ser zero!"
elif receita == 0:
mensagem = "A receita gerada não pode ser zero!"
else:
roas = receita / custo
mensagem = f"ROAS: {roas:.2f} \n(Para cada €1 investido, ganhou €{roas:.2f})"
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Valor digitado inválido!")
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, 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.4, 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.7, rely=0.65, relwidth=0.25, relheight=0.1)
resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()