from tkinter import *
root = Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Pig Latin")
titulo = Label(text="Pig Latin",
font=("Arial", "55", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.1, rely=0.05)
texto_sub1 = Label(text="Frase:",
font=("Arial", "20", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.1, rely=0.35)
frase = StringVar()
frase_entrada = Entry(textvariable=frase,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
frase_entrada.place(relx=0.33, rely=0.37, relwidth=0.63)
def limpar():
frase_entrada.delete(0, END)
resultado.set("")
def app():
f = frase.get().lower().split()
frase_final = []
for palavra in f:
if palavra[0] in "aeiou":
palavra = palavra + "yay"
else:
palavra = palavra[1:] + palavra[0] + "ay"
frase_final.append(palavra)
resultado.set(" ".join(frase_final))
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.55, 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.55, 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.55, 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.68, relwidth=0.9, relheight=0.3)
root.mainloop()
Comentários
Enviar um comentário