import unicodedata
from tkinter import *
def remover_acentos(palavra):
return ''.join(
c for c in unicodedata.normalize('NFD', palavra)
if unicodedata.category(c) != 'Mn'
)
def gerar_sigla(frase):
ignorar = {"a", "as", "os", "às", "á", "de", "do", "da", "dos", "das", "e"}
palavras = frase.split()
sigla = "".join(
remover_acentos(p[0]).upper()
for p in palavras
if p.lower() not in ignorar and p[0].isalpha()
)
return sigla
def limpar():
resultado_texto.config(text="")
def app():
frase = Frase.get()
sigla = gerar_sigla(frase)
resultado_texto.config(text=f"{sigla}")
root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Gerar Sigla")
titulo = Label(text="Gerar Sigla",
font=("Arial", 35, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.25, rely=0.05)
texto_sub1 = Label(text="Frase:",
font=("Arial", 25, "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.2, rely=0.32)
Frase = StringVar()
Frase_entrada = Entry(textvariable=Frase,
font=("Arial", 12, "bold"),
bg="white", fg="blue", justify='center')
Frase_entrada.place(relx=0.37, rely=0.34, relwidth=0.55)
but1 = Button(text="Mostrar", 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", 20, "bold"), bg="#103030", fg="#49e3e3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()