from tkinter import *
root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Feliz Dia de São Valentim")
titulo = Label(
root,
text="Feliz Dia de São Valentim",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.15, rely=0.05)
texto_sub1 = Label(
root,
text="Nome da pessoa especial:",
font=("Arial", 20, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub1.place(relx=0.05, rely=0.25)
Nome = StringVar()
Nome_entrada = Entry(
root,
textvariable=Nome,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Nome_entrada.place(relx=0.57, rely=0.26, relwidth=0.35)
Nome_entrada.focus()
frame_resultado = Frame(root)
frame_resultado.place(relx=0.05, rely=0.6, relwidth=0.9, relheight=0.33)
scroll = Scrollbar(frame_resultado)
scroll.pack(side=RIGHT, fill=Y)
resultado_texto = Text(
frame_resultado,
font=("Courier", 12, "bold"),
bg="#cfe2f3",
yscrollcommand=scroll.set
)
resultado_texto.pack(side=LEFT, fill=BOTH, expand=True)
scroll.config(command=resultado_texto.yview)
resultado_texto.tag_config("mensagem", foreground="red")
resultado_texto.tag_config("coracao", foreground="deeppink")
def limpar():
Nome_entrada.delete(0, END)
resultado_texto.delete("1.0", END)
def app():
nome = Nome.get().strip()
coracao = [
" *** *** ",
" ***** ***** ",
"******* *******",
" ************* ",
" *********** ",
" ********* ",
" ******* ",
" ***** ",
" *** ",
" * "
]
resultado_texto.delete("1.0", END)
resultado_texto.insert(END,
f"Feliz Dia de São Valentim {nome} \n\n",
"mensagem"
)
for linha in coracao:
resultado_texto.insert(END, linha + "\n", "coracao")
but1 = Button(
root,
text="Mostrar",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.4, relwidth=0.25, relheight=0.1)
but_limpar = Button(
root,
text="Limpar",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=limpar
)
but_limpar.place(relx=0.4, rely=0.4, relwidth=0.25, relheight=0.1)
but_sair = Button(
root,
text="Sair",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=root.destroy
)
but_sair.place(relx=0.7, rely=0.4, relwidth=0.25, relheight=0.1)
root.mainloop()