from tkinter import *
root = Tk()
root.geometry("500x600")
root.resizable(0, 0)
root.config(bg="#103030")
root.title("Desempenho de um jogador")
titulo = Label(text="Desempenho de um jogador",
font=("Arial", "25", "bold"), bg="#103030", fg="#49e3e3")
titulo.place(relx=0.08, rely=0.05)
texto_sub1 = Label(text="Golos :", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub1.place(relx=0.3, rely=0.2)
texto_sub2 = Label(text="Assistências:", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub2.place(relx=0.2, rely=0.3)
texto_sub3 = Label(text="Chances Criadas:", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub3.place(relx=0.13, rely=0.4)
texto_sub4 = Label(text="Faltas Cometidas:", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub4.place(relx=0.13, rely=0.5)
texto_sub5 = Label(text="Erros:", font=("Arial", "18", "bold"), bg="#103030", fg="#49e3e3")
texto_sub5.place(relx=0.38, rely=0.6)
Golos = StringVar()
Golos_entrada = Entry(textvariable=Golos, font=("Arial", "12", "bold"), bg="white", fg="blue", justify='center')
Golos_entrada.place(relx=0.57, rely=0.21, relwidth=0.35)
Golos_entrada.focus()
Assistências = StringVar()
Assistências_entrada = Entry(textvariable=Assistências, font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Assistências_entrada.place(relx=0.57, rely=0.31, relwidth=0.35)
Chances_Criadas = StringVar()
Chances_Criadas_entrada = Entry(textvariable=Chances_Criadas,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Chances_Criadas_entrada.place(relx=0.57, rely=0.41, relwidth=0.35)
Faltas_Cometidas = StringVar()
Faltas_Cometidas_entrada = Entry(textvariable=Faltas_Cometidas,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
Faltas_Cometidas_entrada.place(relx=0.57, rely=0.51, relwidth=0.35)
Erros = StringVar()
Erros_entrada = Entry(textvariable=Erros,
font=("Arial", "12", "bold"), bg="white",
fg="blue", justify='center')
Erros_entrada.place(relx=0.57, rely=0.61, relwidth=0.35)
def limpar():
Erros_entrada.delete(0, END)
Faltas_Cometidas_entrada.delete(0, END)
Golos_entrada.delete(0, END)
Assistências_entrada.delete(0, END)
Chances_Criadas_entrada.delete(0, END)
resultado_texto.config(text="")
def _calculate():
try:
G = int(Golos.get())
Fal_cometidas = int(Faltas_Cometidas.get())
A = int(Assistências.get())
Chances = int(Chances_Criadas.get())
E = int(Erros.get())
Avaliação = G * 4 + A * 3 + Chances * 1 - Fal_cometidas * 1 - E * 2
mensagem = f"Pontuação do jogador: {Avaliação}"
resultado_texto.config(text=mensagem)
except ValueError:
resultado_texto.config(text="Valor digitado inválido!!")
def app(event=None):
_calculate()
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=_calculate)
but1.place(relx=0.1, rely=0.67, 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.67, 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.67, relwidth=0.25, relheight=0.1)
root.bind('<Return>', app)
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()
Comentários
Enviar um comentário