import random
from tkinter import *
root = Tk()
root.geometry("500x500")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Sorteio")
titulo = Label(root, text="Sorteio",
font=("Arial", 28, "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.35, rely=0.05)
escolha_var = StringVar()
Label(root, text="Selecione sua hipótese:", font=("Arial", 15, "bold"),
bg="#103030", fg="#49e3e3").place(relx=0.1, rely=0.15)
hipoteses = ["Hipótese 1", "Hipótese 2", "Hipótese 3", "Hipótese 4", "Hipótese 5"]
premio_indices = ["vazio", "vazio", "Carro", "vazio", "vazio"]
premio = random.choice(premio_indices)
premio_index = premio_indices.index(premio)
for idx, opcao in enumerate(hipoteses):
Radiobutton(root, text=opcao, variable=escolha_var, value=idx, bg="white", fg="#103030",
font=("Arial", 14)).place(relx=0.35, rely=0.2 + idx*0.07)
def novo_sorteio():
global premio, premio_index
premio = random.choice(premio_indices)
premio_index = premio_indices.index(premio)
resultado_texto.config(text="")
but1.config(state=NORMAL)
def app():
try:
e = int(escolha_var.get())
if e == premio_index:
resultado_texto.config(text=f"Parabéns! Você encontrou o prémio! ({premio})")
else:
resultado_texto.config(text=f"Que pena, falhou o prémio!")
but1.config(state=DISABLED)
except ValueError:
resultado_texto.config(text="Por favor, selecione uma hipótese.")
but1 = Button(text="Mostrar", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.1, rely=0.65, relwidth=0.25, relheight=0.1)
but_sorteio = Button(text="Novo Sorteio", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=novo_sorteio)
but_sorteio.place(relx=0.4, rely=0.65, 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.65, relwidth=0.25, relheight=0.1)
resultado_texto = Label(text="",
font=("Arial", 12, "bold"), bg="#cfe2f3")
resultado_texto.place(relx=0.05, rely=0.8, relwidth=0.9, relheight=0.15)
root.mainloop()