from tkinter import *
root=Tk()
root.geometry("400x400")
root.resizable(0, 0)
root.config(bg="#d9ead3")
root.title("Grade Calculator")
def limpar():
valor_English_entrada.delete(0, END)
valor_Analytical_Skill_entrada.delete(0, END)
valor_General_Knowledge_entrada.delete(0, END)
def app():
e = int(valor_English.get())
capacidade =int( valor_Analytical_Skill.get())
conhecimento=int(valor_General_Knowledge_entrada.get())
total = e + capacidade +conhecimento
media = total/3
mediaarr = round(media,2)
if mediaarr >50:
grade = "Pass"
resultado_Grade_texto['fg'] = "green"
else:
grade = "Fail"
resultado_Grade_texto['fg'] = "red"
resultado_Total.set(total), resultado_Average.set(mediaarr),resultado_Grade.set(grade)
texto_sub1 = Label(text="English:", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub1.place(relx=0.3, rely=0.15)
texto_sub2 = Label(text="Analytical Skill :", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub2.place(relx=0.17, rely=0.25)
texto_sub3 = Label(text="General Knowledge :", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub3.place(relx=0.08, rely=0.35)
texto_sub4 = Label(text="Total :", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub4.place(relx=0.3, rely=0.45)
texto_sub5 = Label(text="Average :", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub5.place(relx=0.25, rely=0.55)
texto_sub6 = Label(text="Grade :", font=("Arial", "12", "bold"),bg="#d9ead3",fg="#bf9000")
texto_sub6.place(relx=0.25, rely=0.65)
valor_English = IntVar()
valor_English_entrada = Entry(textvariable=valor_English,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_English_entrada.place(relx=0.5, rely=0.15, relwidth=0.3)
valor_Analytical_Skill = IntVar()
valor_Analytical_Skill_entrada = Entry(textvariable=valor_Analytical_Skill,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_Analytical_Skill_entrada.place(relx=0.5, rely=0.25, relwidth=0.3)
General_Knowledge = IntVar()
valor_General_Knowledge_entrada = Entry(textvariable=General_Knowledge,
font=("Arial", "12", "bold"),
bg="white", fg="blue", justify='center')
valor_General_Knowledge_entrada.place(relx=0.5, rely=0.35, relwidth=0.3)
#
but1 = Button(text="Calcular", bd=2, bg='#107db2', fg='white',
font=('verdana', 12, 'bold'), command=app)
but1.place(relx=0.3, rely=0.8, relwidth=0.2, 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.55, rely=0.8, relwidth=0.2, relheight=0.1)
resultado_Total = StringVar()
resultado_Total_texto = Label(textvariable=resultado_Total,
font=("Arial", 12, "bold"), bg="#f0f8ff")
resultado_Total_texto.place(relx=0.5, rely=0.45, relwidth=0.3)
resultado_Average = StringVar()
resultado_Average_texto = Label(textvariable=resultado_Average,
font=("Arial", 12, "bold"), bg="#f0f8ff")
resultado_Average_texto.place(relx=0.5, rely=0.55, relwidth=0.3)
resultado_Grade = StringVar()
resultado_Grade_texto = Label(textvariable=resultado_Grade,
font=("Arial", 12, "bold"), bg="#f0f8ff")
resultado_Grade_texto.place(relx=0.5, rely=0.65, relwidth=0.3)
root.mainloop()