from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Calcular Compatibilidade")
titulo = Label(text="Calcular Compatibilidade",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.05, rely=0.05)
sub1 = Label(text="Nome da primeira pessoa: ", font=("Arial", "13", "bold"), bg="#103030", fg="#49e3e3")
sub1.place(relx=0.05, rely=0.26)
nome_primeiro = StringVar()
nome_primeiro_entrada = Entry(textvariable=nome_primeiro, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
nome_primeiro_entrada.place(relx=0.6, rely=0.26, relwidth=0.35)
nome_primeiro_entrada.focus()
sub2 = Label(text="Nome da segunda pessoa: ", font=("Arial", "13", "bold"), bg="#103030", fg="#49e3e3")
sub2.place(relx=0.05, rely=0.36)
nome_segundo = StringVar()
nome_segundo_entrada = Entry(textvariable=nome_segundo, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
nome_segundo_entrada.place(relx=0.6, rely=0.36, relwidth=0.35)
nome_segundo_entrada.focus()
def limpar():
nome_segundo_entrada.delete(0,END)
nome_primeiro_entrada.delete(0,END)
resultado_texto.config(text="")
def app():
n1 = nome_primeiro.get()
n2= nome_segundo.get()
contador = 0
for letra in n1:
if letra in n2:
contador += 1
compatibilidade = (contador / max(len(n1), len(n2))) * 100
mensagem = f"A compatibilidade entre\n {n1} e {n2}\n é de {compatibilidade:.2f}%."
resultado_texto.config(text=mensagem)
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.5, 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.5, 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.5, relwidth=0.25, relheight=0.1)
resultado_texto = Label(font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.63, relwidth=0.9, relheight=0.3)
root.mainloop()