from tkinter import *
root = Tk()
root.geometry("400x250")
root.resizable(0, 0)
root.config(bg="#9fc5e8")
root.title("Anagrama")
def app():
p1 = Palavra1.get()
p2 = Palavra2.get()
str1 = p1.replace(' ', '').lower()
str2 = p2.replace(' ', '').lower()
if len(str1) != len(str2):
mensagem=f'{str1} e {str2} não são anagramas!'
if sorted(str1) == sorted(str2):
mensagem = f'{str1} e {str2} são anagramas!'
else:
mensagem = f'{str1} e {str2} não são anagramas!'
resultado.set(mensagem)
def limpar():
Palavra1_entrada.delete(0, END)
Palavra2_entrada.delete(0, END)
titulo = Label(text="Anagrama",
font=("Arial", "18", "bold"),bg="#9fc5e8",fg="#7f6000")
titulo.place(relx=0.35, rely=0.05)
texto_sub1 = Label(text="Palavra 1 :",
font=("Arial", "13", "bold"),bg="#9fc5e8",fg="#bf9000")
texto_sub1.place(relx=0.2, rely=0.3)
texto_sub2 = Label(text="Palavra 2 :",
font=("Arial", "13", "bold"),bg="#9fc5e8",fg="#bf9000")
texto_sub2.place(relx=0.2, rely=0.45)
Palavra1 = StringVar()
Palavra1_entrada = Entry(textvariable=Palavra1,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Palavra1_entrada.place(relx=0.45, rely=0.3, relwidth=0.35)
Palavra2 = StringVar()
Palavra2_entrada = Entry(textvariable=Palavra2,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Palavra2_entrada.place(relx=0.45, rely=0.45,relwidth=0.35)
#
but1 = Button(text="Validar", 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)
texto_sub3 = Label(text="Resultado",
font=("Arial", "13", "bold"),bg="#9fc5e8",fg="#bf9000")
texto_sub3.place(relx=0.45, rely=0.75)
resultado = StringVar()
resultado_texto = Label(textvariable=resultado,
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.85, relwidth=0.9,relheight=0.1)
root.mainloop()