from tkinter import *
import random
root = Tk()
root.geometry("700x350")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Alistamento militar tailandês por sorteio")
titulo = Label(
root,
text="Alistamento Tailandês por sorteio",
font=("Arial", 28, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.05, rely=0.05)
def limpar():
root.config(bg="#103030")
titulo.config(bg="#103030")
resultado_texto.config(text="", bg="#cfe2f3", fg="black")
def app():
escolha = random.choice(["Preto", "Vermelho"])
if escolha == "Preto":
mensagem = "Está safo do serviço militar"
cor_fundo = "black"
else:
mensagem = "Vai ter de cumprir o serviço militar"
cor_fundo = "red"
mensagem = f"{escolha} → {mensagem}"
# mudar cores
root.config(bg=cor_fundo)
titulo.config(bg=cor_fundo)
resultado_texto.config(
text=mensagem,
bg=cor_fundo,
fg="white"
)
# Botões
but1 = Button(root, text="Sorteio", 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(root, 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(root, 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)
resultado_texto = Label(
root,
text="",
font=("Arial", 12, "bold"),
bg="#cfe2f3"
)
resultado_texto.place(relx=0.05, rely=0.5, relwidth=0.9, relheight=0.4)
root.mainloop()