from tkinter import *
import random
sujeitos = [
"O vento frio",
"A neve silenciosa",
"O crepúsculo de inverno",
"A luz pálida do sol",
"A brisa gelada da manhã"
]
verbos = [
"acaricia",
"envolve",
"transforma",
"revela",
"desperta"
]
objetos = [
"as ruas vazias",
"os pensamentos adormecidos",
"os sonhos guardados",
"as janelas iluminadas",
"a alma que procura aconchego"
]
finais = [
"com um toque de magia.",
"num silêncio que conforta.",
"com a promessa de novos começos.",
"num brilho que só o inverno conhece.",
"como se contasse histórias antigas."
]
root = Tk()
root.geometry("700x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Gerar frases")
titulo = Label(
text="Gerar frases",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.35, rely=0.05)
# Limpar texto
def limpar():
resultado_texto.config(text="")
# Gerar frase
def app():
mensagem = (
f"{random.choice(sujeitos)} "
f"{random.choice(verbos)} "
f"{random.choice(objetos)} "
f"{random.choice(finais)}"
)
resultado_texto.config(text=mensagem)
# Botões
but1 = Button(
text="Gerar",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.25, 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.25, 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.25, relwidth=0.25, relheight=0.1)
resultado_texto = Label(
text="",
font=("Arial", 16, "bold"),
bg="#cfe2f3",
fg="#103030",
wraplength=650,
justify="center",
padx=20,
pady=20
)
resultado_texto.place(relx=0.05, rely=0.45, relwidth=0.9, relheight=0.5)
root.mainloop()