Mundo em Python

SIMULADOR DE SORTE DO DIA

from tkinter import *
import random
from datetime import datetime root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("SIMULADOR DE SORTE DO DIA ") titulo = Label(
text="SIMULADOR DE SORTE DO DIA",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.1, rely=0.05) resultado_texto = Label(
text="",
font=("Arial", 14, "bold"),
bg="#cfe2f3",
justify="left",
anchor="nw"
)
resultado_texto.place(relx=0.05, rely=0.46, relwidth=0.9, relheight=0.4) animando = False

def animacao(cont=0):
global animando if cont < 15:
numero = random.randint(1, 100)
resultado_texto.config(text=f"A calcular sorte...\n\n{numero}/100")
root.after(80, lambda: animacao(cont + 1))
else:
mostrar_resultado()
def mostrar_resultado():
global animando
animando = False

seed = int(datetime.now().strftime("%Y%m%d"))
random.seed(seed) sorte = random.randint(1, 100) mensagem = (
f"Data: {datetime.now().strftime('%d/%m/%Y')}\n"
f"Sorte de hoje: {sorte}/100\n\n"
) if sorte >= 80:
mensagem += "Dia MUITO favorável! Aproveita oportunidades grandes."
elif sorte >= 60:
mensagem += "Boa sorte! As coisas tendem a correr bem."
elif sorte >= 40:
mensagem += "Sorte neutra. Depende mais das tuas escolhas."
elif sorte >= 20:
mensagem += "Dia com alguns desafios. Vai com calma."
else:
mensagem += "Dia mais difícil. Evita riscos desnecessários."

mensagem += "\n\nDica: mantém o foco e não forces decisões."

resultado_texto.config(text=mensagem)
def app():
global animando
if not animando:
animando = True
animacao()
def limpar():
resultado_texto.config(text="") # BOTÕES
but1 = Button(
text="SIMULADOR ",
bd=2,
bg='#107db2',
fg='white',
font=('verdana', 12, 'bold'),
command=app
)
but1.place(relx=0.1, rely=0.3, 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.3, 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.3, relwidth=0.25, relheight=0.1) root.mainloop()
0