Mundo em Python

Alfabeto Fonético do NYPD

from tkinter import *

root = Tk()
root.geometry("700x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Alfabeto Fonético do NYPD")
nypd_alphabet = {
'A': 'Adam', 'B': 'Boy', 'C': 'Charlie', 'D': 'David', 'E': 'Edward',
'F': 'Frank', 'G': 'George', 'H': 'Henry', 'I': 'Ida', 'J': 'John',
'K': 'King', 'L': 'Lincoln', 'M': 'Mary', 'N': 'Nora', 'O': 'Ocean',
'P': 'Peter', 'Q': 'Queen', 'R': 'Robert', 'S': 'Sam', 'T': 'Tom',
'U': 'Union', 'V': 'Victor', 'W': 'William', 'X': 'X-ray', 'Y': 'Young', 'Z': 'Zebra'
}
titulo = Label(
text="Alfabeto Fonético do NYPD", font=("Arial", 28, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.15, rely=0.05) texto_sub1 = Label(
text="Texto:", font=("Arial", 18, "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.1, rely=0.25) texto = StringVar()
texto_entrada = Entry(
textvariable=texto,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
texto_entrada.place(relx=0.25, rely=0.26, relwidth=0.65)
texto_entrada.focus()
def limpar():
texto_entrada.delete(0, END)
resultado_texto.config(text="")
def app():
entrada = texto.get().upper()
resultado = [] for letra in entrada:
if letra in nypd_alphabet:
resultado.append(nypd_alphabet[letra])
elif letra == " ":
resultado.append(" ") # Mantém espaços
else:
resultado.append(letra) # Mantém números ou símbolos

resultado_final = "-".join(resultado).replace("- -", " [Espaço] ")
resultado_texto.config(text=resultado_final)
# Botões
but1 = Button(
text="Converter",
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(
text="",
font=("Arial", 12, "bold"),
bg="#cfe2f3",
fg="#103030",
wraplength=600
)
resultado_texto.place(relx=0.05, rely=0.65, relwidth=0.9, relheight=0.3) root.mainloop()
0