import random
from tkinter import *
possibilidades = {
"Racing Genk": ["Dínamo", "Brann"],
"Bologna ": ["Dínamo", "Brann"],
"VfB Stuttgart": ["Celtic", "Ludogorets"],
"Ferencvárosi": ["Celtic", "Ludogorets"],
"Nottingham Forest": ["Fenerbahçe", "Panathinaikos"],
"Viktoria Plzen": ["Fenerbahçe", "Panathinaikos"],
"Estrela Vermelha": ["PAOK", "LOSC Lille"],
"Celta de Vigo": ["PAOK", "LOSC Lille"]
}
def sortear_playoffs(mapa):
while True:
restantes = set(time for lista in mapa.values() for time in lista)
confrontos = {}
seeds = list(mapa.keys())
random.shuffle(seeds)
valido = True
for seed in seeds:
opcoes = [t for t in mapa[seed] if t in restantes]
if not opcoes:
valido = False
break
adversario = random.choice(opcoes)
confrontos[seed] = adversario
restantes.remove(adversario)
if valido:
return confrontos
root = Tk()
root.geometry("700x400")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Simulador de sorteio dos playoffs da Liga da Europa")
titulo = Label(
text="Simulador de sorteio dos playoffs da Liga da Europa",
font=("Arial", 19, "bold"),
bg="#103030",
fg="#49e3e3"
)
titulo.place(relx=0.05, rely=0.05)
def limpar():
resultado_texto.config(text="")
def app():
resultado = sortear_playoffs(possibilidades)
texto = "SORTEIO DOS PLAYOFFS \n\n"
for seed, adv in resultado.items():
texto += f"{seed} x {adv}\n"
resultado_texto.config(text=texto)
but1 = Button(
text="Mostrar",
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", 12, "bold"),
bg="#cfe2f3",
justify=LEFT,
anchor="nw"
)
resultado_texto.place(relx=0.05, rely=0.45, relwidth=0.9, relheight=0.5)
root.mainloop()
Comentários
Enviar um comentário