Mundo em Python

Oráculo Mágico

import random
import time
from tkinter import * root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Oráculo Mágico") titulo = Label(
text="Bem-vindo ao Oráculo Mágico!",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.08, rely=0.05) texto_sub1 = Label(
text="Pergunta:",
font=("Arial", 20, "bold"),
bg="#103030",
fg="#49e3e3"
)
texto_sub1.place(relx=0.05, rely=0.32) Pergunta = StringVar()
Pergunta_entrada = Entry(
textvariable=Pergunta,
font=("Arial", 12, "bold"),
bg="white",
fg="blue",
justify='center'
)
Pergunta_entrada.place(relx=0.25, rely=0.33, relwidth=0.7) respostas = [
"Sim", "Não", "Talvez", "Com certeza!",
"Nem pensar!", "Pergunte novamente depois...",
"As estrelas dizem que sim...", "O destino é incerto..."
]
def limpar():
resultado_texto.config(text="")
def app():
pergunta = Pergunta.get() if pergunta.strip() == "":
mensagem = "Preciso de uma pergunta verdadeira!"
else:
resultado_texto.config(text="Consultando os espíritos...")
root.update()
time.sleep(1.2)
resposta = random.choice(respostas)
mensagem = f"O Oráculo diz: {resposta}"

resultado_texto.config(text=mensagem) but1 = Button(
text="Mostrar",
bd=2,
bg='#107db2',
fg='white',
font=('Verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.45, 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.45, 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.45, relwidth=0.25, relheight=0.1) resultado_texto = Label(
text=" Faça sua pergunta ao Oráculo...",
font=("Arial", 12, "bold"),
bg="#cfe2f3",
wraplength=600,
justify="center"
)
resultado_texto.place(relx=0.05, rely=0.6, relwidth=0.9, relheight=0.35) root.mainloop()
0